LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random number generation, odd and even determination etc.


@RavensFan wrote:

 So 6.5 would round down to 6.  5.5 would round up to 6.  So using regular rounding introduces slightly more biased results there.


i totally did not considered this......easily forgotten, back in core 1  Smiley Surprised

 

1.5 to 2....and 2.5 to 2, rounding to the nearest even number

0 Kudos
Message 11 of 18
(1,335 Views)

Hey again, sorry for the delay. Been rather busy Smiley Frustrated I've tampered with the .vi but still no luck so far, I wasn't able to make it work properly. All ideas are welcome!

0 Kudos
Message 12 of 18
(1,291 Views)

Then attach what you have so far and tell us exactly how it isn't working like you want.

0 Kudos
Message 13 of 18
(1,279 Views)

Yeah, I forgot to add the .vi, my bad. Blame the insomnia Smiley Happy here's the file. I've added a waveform chart as well as a table. But I can't make it distinguish the odds and the even ones, and send the odd number to board #1 and the evens to a board #2. 

Bear in mind that my LabVIEW version is 9.0.

Thanks!

0 Kudos
Message 14 of 18
(1,255 Views)

I don't see 2 tables in your VI.  There were also issues discussed about the rounding that you didn't incorporate either.  I edited your VI to build a single table containing the values and whether it was even or odd.  This is meant as a stepping point for you.


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
Message 15 of 18
(1,252 Views)

There was a discussion on the LAVA forums a few years ago about random integers and rounding.

 

To get an even distribution from low to high, you add one to the high value, then round downward.

 

See the example VI in this post. (Originally by Jim Kring from the openg forums. I simply duplicated it for discussion)

 

http://lavag.org/topic/14981-random-number-integer-numeric-package/#entry90015

 

An alternative to the quotient and remainder technique would be to AND the random integers with 0x01 and compare the results with 0x01. If TRUE, the number would be ODD.

 

Message 16 of 18
(1,230 Views)

Indeed, I didn't use two tables because I couldn't get the second one working, so I left it out. It's a little more clear now, thanks for the heads up. I'll get to work on it right away. 

I hope everyone is learning something from this Smiley Happy

0 Kudos
Message 17 of 18
(1,225 Views)

Yet another way of doing odd/even determination...  it simply does LSB check using bit shifting... as a great soul once said: Do more with less code in less time! Smiley Wink

 

Plus there are plenty of folks out there like myself who don't like usage of strings so much (just personal preference - and also because using boolean & integers is faster). Attached example doesn't use strings but still gives the same result.

 

-DP

(Please don't mind the label for boolean in that cluster, I realize that it should say "Even?")

 

 

untitled.png

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 18 of 18
(1,181 Views)