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

Hi

I am working on a simulation program. How can I use a normal random
variable generator in my VBA code in Excel? There is a function NORMINV
in Excel, but I don't know how to use in my VBA code. The compiler
doesn't know this function. Please help.

Ming





*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Normal Random Variable Generator

?worksheetfunction.NORMINV(0.908789,40,1.5)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ming Shao" wrote in message
...
Hi

I am working on a simulation program. How can I use a normal random
variable generator in my VBA code in Excel? There is a function NORMINV
in Excel, but I don't know how to use in my VBA code. The compiler
doesn't know this function. Please help.

Ming





*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Normal Random Variable Generator

That functon will give you the inverse of the normal probability
density function, not a random normal variable. You can create quasi
random variables in Excel :

Obtain 12 independent samples of rand()-6 and add them toguether.
Rand() gives you a random number between 0 and 1 with from a uniform
distribution.

for x =1 to 12

y=y+application.rnd()

next x

y=y-6
The end result will be a random number with a mean of 0 and a stdev of
1.

this will be a close approximation but fourth and hihger orders may
differ from a normal distribution.




There are other methods top generate more accurate normal random
numbers such as the box mueller

function BM()
randomize
do
x=2*rnd() -1
y=2*rnd() -1
dist= x*x+y*y
loop until dist<1

BM= x*sqr(-2*log(dist)/dist)
end function

cheers.


"Bob Phillips" wrote in message ...
?worksheetfunction.NORMINV(0.908789,40,1.5)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ming Shao" wrote in message
...
Hi

I am working on a simulation program. How can I use a normal random
variable generator in my VBA code in Excel? There is a function NORMINV
in Excel, but I don't know how to use in my VBA code. The compiler
doesn't know this function. Please help.

Ming





*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Normal Random Variable Generator

Depending on how far you trust the various functions involved, NORMSINV
(RND()) will generate normally distributed random values. Just as any
{x}Inv(RND()) will generate a {x}-distributed random variable.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
That functon will give you the inverse of the normal probability
density function, not a random normal variable. You can create quasi
random variables in Excel :

Obtain 12 independent samples of rand()-6 and add them toguether.
Rand() gives you a random number between 0 and 1 with from a uniform
distribution.

for x =1 to 12

y=y+application.rnd()

next x

y=y-6
The end result will be a random number with a mean of 0 and a stdev of
1.

this will be a close approximation but fourth and hihger orders may
differ from a normal distribution.




There are other methods top generate more accurate normal random
numbers such as the box mueller

function BM()
randomize
do
x=2*rnd() -1
y=2*rnd() -1
dist= x*x+y*y
loop until dist<1

BM= x*sqr(-2*log(dist)/dist)
end function

cheers.


"Bob Phillips" wrote in message ...
?worksheetfunction.NORMINV(0.908789,40,1.5)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ming Shao" wrote in message
...
Hi

I am working on a simulation program. How can I use a normal random
variable generator in my VBA code in Excel? There is a function NORMINV
in Excel, but I don't know how to use in my VBA code. The compiler
doesn't know this function. Please help.

Ming





*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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
Random Generator Richard Champlin Excel Discussion (Misc queries) 15 October 26th 07 09:32 PM
Random Name Generator Smeeg Excel Worksheet Functions 5 March 3rd 06 03:25 PM
Random alpha generator bj Excel Worksheet Functions 3 April 27th 05 11:02 PM
Random # Generator vamosj Excel Worksheet Functions 0 November 8th 04 07:14 PM
Random Number Generator Brad[_13_] Excel Programming 4 December 18th 03 03:41 PM


All times are GMT +1. The time now is 10:39 AM.

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"