From: Kaze on
Thanks for all the help.

I don't think I can use num2vpi because I can't install anything on the computer since I don't have the permissions.

I think I need another metode to get the numbers.

A friend help me solve the last problem:
*determine by random selection the proportion of elements of F which satisfy the logical relationship: x*(1/x) == 1

>> x=rand(1,n)*realmin;
>> sum(x.*(1./x)==1)

ans =

1

Now for the second problem, I think I can use this:
*What proportion of elements of F are in the interval [1, 2)?

>> x=rand(1,2)*realmin

x =

1.0e-308 *

0.1541 0.4837

Can you please tell me If I did something wrong and help me with the other two ?

Kind regards.
From: Walter Roberson on
Kaze wrote:
> *What proportion of elements of F are in the interval [1, 2)?
>
>>> x=rand(1,2)*realmin

rand(1,2) does not select values in the range [1,2); instead it creates
a 1 x 2 matrix of random numbers.

From: James Tursa on
"Kaze " <raicabogdan(a)gmail.com> wrote in message <hjfdmi$30m$1(a)fred.mathworks.com>...
>
> I don't think I can use num2vpi because I can't install anything on the computer since I don't have the permissions.

Well, unless you don't have permission to download anything I don't see why this would be an issue. These are just ASCII text files, m-files and C source code. You do have permission to create files, don't you? How would you ever learn MATLAB if you didn't have permission to create files?

> I think I need another metode to get the numbers.

Hmmm. What is wrong with the methods I showed you using direct counting or typecast? Neither one of them require you to download anything.

> A friend help me solve the last problem:
> *determine by random selection the proportion of elements of F which satisfy the logical relationship: x*(1/x) == 1
>
> >> x=rand(1,n)*realmin;

Amazing. You have managed to construct a vector x where absolutely *none* of the elements of x are in F. Exactly the opposite of the posed question.

> >> sum(x.*(1./x)==1)

Good ... except the x you are using is wrong.

> Now for the second problem, I think I can use this:
> *What proportion of elements of F are in the interval [1, 2)?
>
> >> x=rand(1,2)*realmin

A total misuse of rand to get numbers in the interval [1,2). You need to read the doc on rand, and then look *very closely* at the examples I gave you with the direct counting or with typecast. Once you understand either one of them the answer to this question and the other interval question will be very easy. rand has nothing to do with it ... you can get the exact answer analytically with either of the methods I showed you.

James Tursa
From: Kaze on
Sorry James,

Please believe me that I'm over my head here and I'm not trying to ignore you or something like that.

I've download the source code of num2vpi and vpi and is working. Happy for that.

I'm not very sure if this is corect, but still :
2nd
>> ieeemin = typecast(1,'int64')

ieeemin =

4607182418800017408

>> ieeemax = typecast(2,'int64')

ieeemax =

4611686018427387904

>> 2*(double(ieeemax)-double(ieeemin))

ans =

9.0072e+015

3rd
>> ieeemax = typecast((1/32),'int64')

ieeemax =

4584664420663164928

>> ieeemin = typecast((1/64),'int64')

ieeemin =

4580160821035794432

>> 2*(double(ieeemax)-double(ieeemin))

ans =

9.0072e+015

If is not ok, what did I do wrong ?

Regards.
From: James Tursa on
"Kaze " <raicabogdan(a)gmail.com> wrote in message <hjhean$88p$1(a)fred.mathworks.com>...
>
> I'm not very sure if this is corect, but still :
> 2nd
> >> ieeemin = typecast(1,'int64')
> ieeemin =
> 4607182418800017408
> >> ieeemax = typecast(2,'int64')
> ieeemax =
> 4611686018427387904
> >> 2*(double(ieeemax)-double(ieeemin))
> ans =
> 9.0072e+015
>
> 3rd
> >> ieeemax = typecast((1/32),'int64')
> ieeemax =
> 4584664420663164928
> >> ieeemin = typecast((1/64),'int64')
> ieeemin =
> 4580160821035794432
> >> 2*(double(ieeemax)-double(ieeemin))
> ans =
> 9.0072e+015
>
> If is not ok, what did I do wrong ?

Hmmmm ... well, now isn't that curious? You got the same answer for the number of elements of F in the interval [1,2) as in the interval [1/64,1/32). Does that seem right to you? Is that what you expect, or would you expect to get a different answer for these two questions?

James Tursa
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: Differential Equations
Next: figure sizing issue