09-18-2012 03:07 PM
I think you got a nonzero chance to get a 5 digit number once in a while. You probably should round to -infinity somewhere.
09-19-2012 10:55 AM - edited 09-19-2012 11:02 AM
Rounding would ruin your uniform random distribution... probably not enough that you would care.
09-19-2012 11:18 AM
@JW-L3CE wrote:
Rounding would ruin your uniform random distribution... probably not enough that you would care.
That's why you should use the OpenG random number.
http://lavag.org/topic/14981-random-number-integer-numeric-package/page__view__findpost__p__90015
09-19-2012 11:22 AM - edited 09-19-2012 11:23 AM
Well, since we convert to integer, rounding will happen no matter what. The original "toI32" will round to the nearest integer, meaning that the first and last possible bin (0000, and 10000) only have half the typical chance of being populated, and some outcomes will have five digits (10000). Stuff like that could kill all casino profits! 😮
If we multiply by 10000 then round down to the next integer, we get equal probability from 0000 to 9999. A truly uniform random distribution for all possible 4 digit integers! That is the way to go and that's what I proposed earlier. And I do care! 😄
09-19-2012 12:33 PM - edited 09-19-2012 12:36 PM
@altenbach wrote:
Well, since we convert to integer, rounding will happen no matter what. The original "toI32" will round to the nearest integer, meaning that the first and last possible bin (0000, and 10000) only have half the typical chance of being populated, and some outcomes will have five digits (10000). Stuff like that could kill all casino profits! 😮
If we multiply by 10000 then round down to the next integer, we get equal probability from 0000 to 9999. A truly uniform random distribution for all possible 4 digit integers! That is the way to go and that's what I proposed earlier. And I do care! 😄
My bad, I read the "0-1" and not "less than 1". I was picturing poor ole 10000 with a 1/10000 chance. I should know better, I used RNGs all the time in Matlab. Not much reason to use them in them in test systems, heh.
They need a forum prompt: "Are you SURE you want to correct Altenbach?" with button "I rethought it, NO" and "Your funeral".
09-20-2012 06:54 AM
Thanks Christian,
I only needed to generate two random numbers to create unique indexes.
I do like what you suggested and will apply it as a good coding practice. I also like the openG version.
Since this didn't turn out to be a Rube, it is more of a good coding practice example, maybe it is time to create yet another thread to discuss good coding practice.
09-20-2012 07:16 AM
So I helped inspire you? At it early I see.
09-20-2012 07:52 AM
You always inspire me, Putnam 🙂
Especially with your travels.. 🙂
09-21-2012 02:49 AM
Seems I made my own little bit of Rube recently...
That's what you get for reducing code from somewhere else and not rechecking the logic. (the shame)
09-24-2012 02:31 AM - edited 09-24-2012 02:32 AM
How many primitves do you need to make a subVI that returns one row and one column from a 2D array?
A single "index array" primitive would probably be sufficient (bottom), but we could also do it using 8 primitives and 4 diagram constants (top)