Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Non Uniform Random Number Generator

Hi All,

I am trying to figure out a way for Excel to generate a random number
that is based on a KNOWN distribution.

For example, I have downloaded monthly returns for the S&P and
histogramed it out to find the distribution with mean and stddev.

Now I would like Excel to generate a random monthly return based on
the historical distribution. The only way I have down this is to have
a randomly selected row get generated and use that return as my number

Is there a more elegant way?

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Non Uniform Random Number Generator

use a normal ditribution macro with input values in cells C3 .. C6

see : http://www.anthony-vba.kefra.com/vba/vba4.htm

regards

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,059
Default Non Uniform Random Number Generator

On Oct 27, 4:24*pm, busboy10 wrote:
I have downloaded monthly returns for the S&P and
histogramed it out to find the distribution with mean and stddev.
Now I would like Excel to generate a random monthly return based on
the historical distribution.


Suppose the mean is in A1 and std dev is in A2. Then use:

=NORMINV(RAND(),A1,A2)

Caveat: RAND() is a volatile function. So the formula will be
recalculated after editing any cell in any worksheet of the workbook.
One way to avoid that is to use the myRand() UDF below. You can use
it exactly as you use RAND(). Or you can use myRand(X1), which will
recalculate any formula with that expression after you edit X1,
including simply selecting X1and pressing F2 then Enter.

Function myRand(Optional r As Range) As Double
myRand = Evaluate("rand()")
End Function

To enter myRand(), press atl+F11 to open a VBA window, click Insert
Module to open a VBA module editing pane, and copy-and-paste the above
text into the editing pane. You can now close the VBA window.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
Random Number Generator help Shani Excel Programming 4 April 27th 06 04:25 PM
Random Number generator Neil M Excel Worksheet Functions 2 February 1st 06 06:00 PM
Random Number Generator STEVEB Excel Programming 1 July 22nd 05 09:42 PM
Random Number Generator Sophia[_2_] Excel Programming 8 May 19th 04 02:11 PM


All times are GMT +1. The time now is 12:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"