-
Solved: Normal distribution
Hello
I know that I can draw a random number from a uniform distribution using the following code:
[vba]
dim number as long
dim maxval as long
dim minval as long
maxval = 20
minval = 10
randomize
Number = Int((MaxVal - MinVal + 1) * Rnd + MinVal)
[/vba]
However, I would like to draw a random number from a normal distribution, where I have specified the mean and the standard deviation.
How do I do that? Is it possible to use the data analysis tool via VBA. That is write a VBA code that returns a random number from a given normal distribution - perhaps using the data analysis tool.
Your help is appreciated.
Thank you
Regards Troels
-
I think...:
on a sheet the formula:
=NORMINV(rand(),mean,standard_dev)
In VBA:[vba]Number = Application.WorksheetFunction.NormInv(Rnd(), 0.55, 0.2)[/vba] where .55 is the mean and .2 is the standard deviation.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules