Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random value given a standard normal distribution and mean?
#1
I am trying to do a simulation of projected sales. I can't get my head around how to create a random number that follows a certain probability distribution, specifically the standard normal distribution.

Given a mean of sample_mean and a standard deviation of sample_sd, how can I get a random number off of them? Anyone?

Here is a website that does this, but I can't convert the .class files into meaningful code...

http://www-stat.stanford.edu/~naras/jsm/...lity.class
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#2
You might be better off with the source.
Reply
#3
Hey, thanks, but that's actually not it, er.. it doesn't give a random number.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#4
Hmm, you're right... I didn't actually read it. :oops: No idea then, sorry... I think I've read about such things before, but the importance of having "good" random numbers escaped me at the time (and still does Smile )...
Reply
#5
I figured out a nice way to translate the sample into a distribution from which you can draw random vars from.

Code:
for j = 1 to test_var_amount
test_var = 0
for i = 1 to sample_amount
test_var = test_var + sample_var(i)
next i
test_var = test_var / sample
next j
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
Why not just do this (for instance):
Code:
[pseudocode]
r=random number from 1 to 4, inclusive
if r is 1 or r is 2 then call A()
if r is 3 then call B()
if r is 4 then call C()
[/pseudocode]
That way there is a 50% chance of A() being called, and a 25% of B or C being called.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#7
Use the RND to index in an acumulated distribution table... Or as an entry to a function returning the acumulated distribution.
Antoni
Reply
#8
Antoni Gual: Yeah, it is a good way to do it, but you need to actually create the distributions first for each value..

Zack, that's basically what Antoni is suggesting except a lot more convoluted. :wink:

But it's ok, I figured it out.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)