LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number generator from a distribution with an specified mean and variance?

Hi,

I guess i am a bit confused..

First of all, let's be sure that you know what i'm looking for: i want to get values following a dessired distribution function. Is that what your proposed algorithm makes? if so, where do we have the points?

Analizing your algorithm, this is what i guess it does: from an array conteining the values of the probability density function, you draw it, you build the probability distribution function, and then... i get lost. I guess that what you are trying to do is to build a "simulated" probability distribution function. Every time you get a number, you add 1 to the equivalent position of a 0 array, so the real probability distribution function is suposed to be drawn. But i guess it doesn't work (at least in my laptop with LV7.0). You can find encolosed my suggestion to do this. Basically, for each number taken from the array (x), I look for its equivalent position in a 0 array (500 + x*500/2 for an array of1000 values), and I add 1 in this array. This will be the "simulated" distribution probability function. What do you think about it?

Another point, i would like to know  what do you think about the way of generating random points from a normal distribution that I'm using in secuence 2: if i have an array of 1000 elements that i know they are following the probability distribution, i just select one value each iteration using the random generator. Are this values following the same probability distribution? In case they are, it will be ok for me, it's what i'm looking for. I know it's not necessary to say this, but whatever your answer is, i would like you to be sure about it.

Thank you very much to all of you for your time! 🙂
0 Kudos
Message 21 of 26
(2,724 Views)
Why in the world would you use a waveform chart in your code??? Only a waveform graph seems suitable for a histogram.
 
And why are you writing to a local variable instead of the terminal inside the loop?
 
Also: when building the distribution in frame 1, there is no reason to built an array in a shift register. Simply autoindex the scalar function value at the left loop boundary. The input terminals belong outside the loop because the values should not change during loop execution.
 
Also: Your function does not give a normal distribution. The "dice" gives an even distribution between 0 and 1 and none of your scaling will change that.
0 Kudos
Message 22 of 26
(2,717 Views)


@altenbach wrote:
...Simply autoindex the scalar function value at the left loop boundary.

Sorry, of course I meant "...at the right loop boundary"
0 Kudos
Message 23 of 26
(2,706 Views)
Hi,

Why in the world would you use a waveform chart in your code??? Only a waveform graph seems suitable for a histogram.

Just inexperience..



And why are you writing to a local variable instead of the terminal inside the loop?

I am used to do it, but I know it's not necesary to do this.



Also: when building the distribution in frame 1, there is no reason to built an array in a shift register. Simply autoindex the scalar function value at the left loop boundary. The input terminals belong outside the loop because the values should not change during loop execution.

Thanks, understood.



Also: Your function does not give a normal distribution. The "dice" gives an even distribution between 0 and 1 and none of your scaling will change that.

Sure you are right... now i see it more clearly. Thanks!!



So, now, my last doubt, i hope someone can answer me: I pick up numbers randomly from an array of values which i know they come from a probability distribution. Are these picked up values following the probability distribution too?

Thank you very much for your time 🙂



0 Kudos
Message 24 of 26
(2,696 Views)


@javivi wrote:
So, now, my last doubt, i hope someone can answer me: I pick up numbers randomly from an array of values which i know they come from a probability distribution. Are these picked up values following the probability distribution too?

Only if that array is of near infinite size. In all other cases you will get a distribution from a set of finite values and thus statistically suspect. Here's an example:

Of course if you always get a new array with gaussian noise, it might be OK. In this case you might as well just get a fresh gaussian white noise array with one element each time and leave out the random indexing, right?

There is also a very simple formula to get a normal distributed random number from two even distributed random numbers, (it was actually used on the texas instruments programmable calculators in the seventies). Maybe I can find it somewhere. If I remember right, I implemented it in LabVIEW about 10 years ago. 😉

Message Edited by altenbach on 04-17-2007 10:14 AM

Download All
0 Kudos
Message 25 of 26
(2,691 Views)


@altenbach wrote:
There is also a very simple formula to get a normal distributed random number from two even distributed random numbers, (it was actually used on the texas instruments programmable calculators in the seventies). Maybe I can find it somewhere. If I remember right, I implemented it in LabVIEW about 10 years ago. 😉


OK, found it! To generate a normal distributed random number, you can use the Box-Muller algorithm (look it up!). A simple LabVIEW implementation is shown here:

Message Edited by altenbach on 04-17-2007 10:49 AM

Message 26 of 26
(2,684 Views)