07-07-2021 12:35 PM
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.
Solved! Go to Solution.
07-07-2021 12:55 PM - edited 07-07-2021 12:59 PM
Use the Random Number (Range).vi
If you have an older version without that vi this should do about the same thing:
07-07-2021 12:56 PM
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.
07-07-2021 03:55 PM
https://lavag.org/topic/14981-random-number-integer-numeric-package/
07-08-2021 09:17 AM - edited 07-08-2021 09:18 AM
@johntrich1971 wrote:
I'm not going to do this homework problem for you...
Too late, RTSLVU already did. 😀
07-08-2021 09:33 AM
@Frozen wrote:
@johntrich1971 wrote:
I'm not going to do this homework problem for you...
Too late, RTSLVU already did. 😀
Yeah, that happened while I was replying. 😁
07-08-2021 11:00 AM - edited 07-08-2021 11:01 AM
@johntrich1971 wrote:
@Frozen wrote:
@johntrich1971 wrote:
I'm not going to do this homework problem for you...
Too late, RTSLVU 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?".
07-08-2021 11:09 AM
@RTSLVU wrote:
@johntrich1971 wrote:
@Frozen wrote:
@johntrich1971 wrote:
I'm not going to do this homework problem for you...
Too late, RTSLVU 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. 🏆
07-08-2021 11:42 AM
@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. 😄
07-08-2021 12:11 PM
@Frozen wrote:
@RTSLVU wrote:
@johntrich1971 wrote:
@Frozen wrote:
@johntrich1971 wrote:
I'm not going to do this homework problem for you...
Too late, RTSLVU 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.