Post Reply 
SQRT(RAN#×RAN#) - what is the distribution?
04-06-2019, 03:17 PM (This post was last modified: 04-06-2019 03:20 PM by Csaba Tizedes.)
Post: #1
SQRT(RAN#×RAN#) - what is the distribution?
I am working on double (2D) integration routines just for fun on various calculators (implemented two versions (trapezoidal and Simpson's method) on CASIO fx-3650P and on a TI-83 plus - see the video below) and this weekend I want to write a Monte Carlo method for integration (first 1D later 2D).

Unfortunately on CASIOs we have random number generation from 0.000 to 0.999 increased by 0.001, that is 1000 different random numbers equally spaced. My first idea was that, I can increase the number of different random numbers, if I calculate SQRT(RAN#×RAN#). I am sure this will increase the number of numbers, but what about the distribution?

If you have any suggestion about how it can be figure out, please post here. I don't want to make it in EXCEL or write a brute force - thank you!

And my video about a 2D integration on a TI-83 with sightseeing in Budapest, Hungary - check it on YT, the description below the video fullfilled with informations and you can download the 83's program directly:




Csaba
Find all posts by this user
Quote this message in a reply
04-06-2019, 03:53 PM
Post: #2
RE: SQRT(RAN#×RAN#) - what is the distribution?
For a linear distribution, how about: (RAN# / 1e3) + RAN#

Or: (RAN# / 1e6) + (RAN# / 1e3) + RAN#

Or even: (RAN# / 1e9) + (RAN# / 1e6) + (RAN# / 1e3) + RAN#

— Ian Abbott
Find all posts by this user
Quote this message in a reply
04-06-2019, 07:40 PM
Post: #3
RE: SQRT(RAN#×RAN#) - what is the distribution?
(04-06-2019 03:53 PM)ijabbott Wrote:  For a linear distribution, how about: (RAN# / 1e3) + RAN#

Or: (RAN# / 1e6) + (RAN# / 1e3) + RAN#

Or even: (RAN# / 1e9) + (RAN# / 1e6) + (RAN# / 1e3) + RAN#
Too much steps required, but really good idea!
Find all posts by this user
Quote this message in a reply
04-06-2019, 09:54 PM
Post: #4
RE: SQRT(RAN#×RAN#) - what is the distribution?
.
Hi,

(04-06-2019 03:17 PM)Csaba Tizedes Wrote:  My first idea was that, I can increase the number of different random numbers, if I calculate SQRT(RAN#×RAN#). I am sure this will increase the number of numbers, but what about the distribution?

What you're doing essentially amounts to returning as your random number the geometric mean of two other random numbers and this will certainly never result in a uniform distribution for your returned value if that was the distribution of the two factors. Take logarithms if you doubt it.

Also, you're essentially multiplying two 3-digit integer numbers from 000 to 999, (then dividing by 106) so you'll never get one million different values as you should, first because multiplication is commutative so you'd only get half that many, but also because all prime numbers less than one million would never appear even once as a product, while numbers with many low divisors would appear muliple times (think of, say 36 and 37: the latter, being prime, would never appear as a product while the former would appear as the result of 1*36, 2*18, 3*12, 4*9, 6*6, ...) and this would ruin even further the uniformity, there would be some very strong bias for certain numbers.

ijabbott ideas are the way to go: simple, fast and effective.

Finally, may I suggest that instead of using a pure MonteCarlo scheme, which converges to the correct integral on the order of 1/Sqrt(N), i.e., dismayingly slowly, you migh want to consider a Quasi-MonteCarlo procedure, which converges much faster while still retaining most advantages of MonteCarlo methods in general. Just saying.

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-21-2019, 08:58 PM (This post was last modified: 04-22-2019 11:15 AM by Albert Chan.)
Post: #5
RE: SQRT(RAN#×RAN#) - what is the distribution?
Looking for the easiest way to see distribution of data, I use Minitab (30 years old DOS copy!)

MTB > random 1000 c1-c2;
SUBC> uniform 0 1.
MTB > let c3 = sqrt(c1*c2)
MTB > hist c3

Histogram of C3 N = 1000, Each * represents 5 obs, X=mid-point, Y=counts
Code:
0.0      23  *****
0.1     101  *********************
0.2     130  **************************
0.3     141  *****************************
0.4     144  *****************************
0.5     154  *******************************
0.6     109  **********************
0.7      75  ***************
0.8      75  ***************
0.9      41  *********
1.0       7  **
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: