BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

I think you got a nonzero chance to get a 5 digit number once in a while. You probably should round to -infinity somewhere.

0 Kudos
Message 1171 of 2,608
(11,233 Views)

Rounding would ruin your uniform random distribution... probably not enough that you would care.

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 1172 of 2,608
(11,186 Views)

@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

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 1173 of 2,608
(11,173 Views)

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! 😄

Message 1174 of 2,608
(11,170 Views)

@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".

 

Josh
Software is never really finished, it's just an acceptable level of broken
Message 1175 of 2,608
(11,148 Views)

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.

0 Kudos
Message 1176 of 2,608
(11,129 Views)

So I helped inspire you? At it early I see.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 1177 of 2,608
(11,116 Views)

You always inspire me, Putnam 🙂

 

Especially with your travels..  🙂

0 Kudos
Message 1178 of 2,608
(11,103 Views)

Seems I made my own little bit of Rube recently...

 

Timing Test 06 beginnings.JPG

 

That's what you get for reducing code from somewhere else and not rechecking the logic. (the shame)  Smiley Embarassed



Never say "Oops." Always say "Ah, interesting!"

Message 1179 of 2,608
(11,066 Views)

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)

 

 

 

(seen here)

Message 1180 of 2,608
(11,012 Views)