From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview and random numbers

Solved!
Go to solution

Hallo,

I have a task on labview about a company of water who fills bottles.So I use a tank that I want to be filled from 285ml (min) to 315ml (max). I have to use random numbers(dice) in a while loop .Every time a random number enters I multiply it with 500 so that I have bigger chance to get in the prefered range.But the numbers my dices give me are the most time out of the (285-315 range).What can I do to make my dice give me numbers close to 285-315 in order to have less errors.

0 Kudos
Message 1 of 11
(1,288 Views)
Solution
Accepted by topic author Dennis99

Use the Random Number (Range).vi

 

rndumber.png

 

If you have an older version without that vi this should do about the same thing:

rnd2.png

========================
=== Engineer Ambiguously ===
========================
Message 2 of 11
(1,275 Views)

With the way you were doing it the value would only be correct about 6% of the time (315-285=30, 30/500=0.06). A little basic Algebra I is all that you need to make your random number scale to be within this range 100% of the time. The random number generator is scaled from 0 to 1 so you need to make your value 285 when the random number is 0 and 315 when it is 1. I'm not going to do this homework problem for you. If you can't figure it out from there on your own perhaps you should pursue a different course of study.

0 Kudos
Message 3 of 11
(1,272 Views)

https://lavag.org/topic/14981-random-number-integer-numeric-package/


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 4 of 11
(1,224 Views)

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 5 of 11
(1,159 Views)

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁

0 Kudos
Message 6 of 11
(1,146 Views)

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 11
(1,127 Views)

@RTSLVU wrote:

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".


Yes, it was specific to using random numbers and sometimes a picture is worth a thousand words. 🏆

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 8 of 11
(1,121 Views)

@Dennis99 wrote:

What can I do to make my dice give me numbers close to 285-315 in order to have less errors.


Well, we are not really sure what "close to" means. Do you want every single random number in this range or do you want the occasional reject to be detected and rejected? For example if the tank is empty, you might get a bottle with 0ml. 😄

0 Kudos
Message 9 of 11
(1,114 Views)

@Frozen wrote:

@RTSLVU wrote:

@johntrich1971 wrote:

@Frozen wrote:

@johntrich1971 wrote:

 I'm not going to do this homework problem for you...


Too late, already did. 😀


Yeah, that happened while I was replying. 😁


It was a simple question, I see no need to bash someone's math skills over it. Specially considering how bad my own math skills suck.

(That's why I use computers)

 

As for it being homework, the question was for a very specific problem they were having, not "Can someone write this program for me?".


Yes, it was specific to using random numbers and sometimes a picture is worth a thousand words. 🏆


Perhaps I was a bit harsh. As soon as I saw random numbers I assumed homework, and that he was in a tech profession that would require a lot of basic Algebra. My daughter has just completed Algebra I so I saw a lot of problems like this. I had hoped that I had described the solution well enough in words to get there. Altenbach did bring up a valid point, though. We all assumed "close to" meant that he really wanted all of the values to be in the range, but perhaps some were to be rejected. 

0 Kudos
Message 10 of 11
(1,103 Views)