Numworks - strange random numbers
|
03-04-2023, 05:10 PM
Post: #1
|
|||
|
|||
Numworks - strange random numbers
Hi,
playing around with the latest Numworks app on Android, I noticed a strange behavior of the random() function. When tested with many pairs of random numbers between 0 and 1, min(random#, random#) should converge to 1/3. And max(random#, random#) to 2/3. However, the Numworks app delivers ~1/2 for both min() and max() instead. My HP Prime confirms the expected results ~1/3 and ~2/3 with its random numbers. Code: sum(k, 1, 10000, min({random(), random()})) / 10000 Am I doing something wrong? What do you get on the real Numworks calculator? P.S. kind of wired is too, that 10001 steps are the maximum for Sum() |
|||
03-04-2023, 08:02 PM
Post: #2
|
|||
|
|||
RE: Numworks - strange random numbers
Tried on https://www.numworks.com/simulator/, it make no sense.
> min({0.5, random()}) 0.5 0.9116125675 0.5 0.5 0.5140082607 0.06554496133 |
|||
03-05-2023, 12:00 AM
Post: #3
|
|||
|
|||
RE: Numworks - strange random numbers
(03-04-2023 05:10 PM)LowTech Wrote: Hi, The real Numworks gets the same 1/2. Numworks seems to use a normal distribution where numbers around .5 are chosen more frequently than numbers approaching 0 or .999999 The probability of a particular random number in other machines is about equal throughout the range. Tom L Cui bono? |
|||
03-05-2023, 12:29 PM
Post: #4
|
|||
|
|||
RE: Numworks - strange random numbers
(03-05-2023 12:00 AM)toml_12953 Wrote: The real Numworks gets the same 1/2. Numworks seems to use a normal distribution where numbers around .5 are chosen more frequently than numbers approaching 0 or .999999 The probability of a particular random number in other machines is about equal throughout the range. Quite possible, but can't find any notes about it in the manual. Anyway, pretty unusual. Are other calculators known to behave like this? |
|||
03-05-2023, 01:17 PM
Post: #5
|
|||
|
|||
RE: Numworks - strange random numbers
There is a bug with list containing random numbers.
The list cannot be sorted, getting minimum or maximum. NUMWORKS> sort({random(), random()}) {0.03173426865, 0.1906006013} {0.9829388464, 0.1990888752} // ? {0.5004268227, 0.4287105828} // ? |
|||
03-05-2023, 02:32 PM
Post: #6
|
|||
|
|||
RE: Numworks - strange random numbers
(03-04-2023 08:02 PM)Albert Chan Wrote: Tried on https://www.numworks.com/simulator/, it make no sense. Could this be a case of min() evaluating the arguments more than once? |
|||
03-06-2023, 08:50 PM
Post: #7
|
|||
|
|||
RE: Numworks - strange random numbers
(03-05-2023 02:32 PM)EdS2 Wrote:(03-04-2023 08:02 PM)Albert Chan Wrote: Tried on https://www.numworks.com/simulator/, it make no sense. I am thinking along the same lines. Perhaps it evaluates each expression in the list, determines which one produced the minimum value, and evaluated that expression again. That would also explain why the average value of min({random(), random()}) would be 0.5. It wouldn't matter what the first two random() calls produced. One of those expressions would be the minimum, so it would evaluate that expression again, i.e. call random() again for the final result. — Ian Abbott |
|||
03-06-2023, 11:27 PM
Post: #8
|
|||
|
|||
RE: Numworks - strange random numbers
(03-23-2020 04:34 PM)Albert Chan Wrote: LN(2) = 2 * probability of integer part of RND/RND is odd > sum(rem(floor(random()/random()),2),k,1,10000) / 5000 2 0 2 ... We expected around log(2) = 0.6931, but getting 0 or 2 only. It seems argument inside sum is evaluated only once. random(), and its cousins, should not be treated as normal function. It should never be optimized away. Unfortunately, it seems Numworks fix is like whack-a-mole game. Example, from github fixed issues: random()-random() gets simplified to 0 Above expression, replacing floor(x) = round(x-0.5) work. > sum(rem(round(random()/random()-0.5),2),k,1,10000) / 5000 0.7034 0.6998 0.6938 ... |
|||
03-07-2023, 04:47 PM
Post: #9
|
|||
|
|||
RE: Numworks - strange random numbers
(03-06-2023 11:27 PM)Albert Chan Wrote: Unfortunately, it seems Numworks fix is like whack-a-mole game. When I print random()-random() I get a number. My OS version is 20.3.0. Tom L Cui bono? |
|||
03-07-2023, 07:41 PM
Post: #10
|
|||
|
|||
RE: Numworks - strange random numbers | |||
03-07-2023, 11:16 PM
Post: #11
|
|||
|
|||
RE: Numworks - strange random numbers
(03-07-2023 07:41 PM)Albert Chan Wrote:(03-07-2023 04:47 PM)toml_12953 Wrote: When I print random()-random() I get a number. My OS version is 20.3.0. Yup. I just upgraded to 20.4.0 and sometimes (random()-random())^2 still comes up negative. Imagine that. random can return imaginary numbers! Tom L Cui bono? |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)