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

Does anyone know how to generate random numbers with lognorma
distributions? I am assuming that I can use the LogInv and LogNormDis
function. But as with the normal distributions, I would assume tha
this would be slow. Does anyone know of a VBA sub that generate
random numbers lognormally

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Log Normal Distribution

EXP(z) where z is a normal random number. In 2003 with the recent patch
for the RAND() function, you could use

=EXP(NORMINV(RAND(),mean,stdev)

but this will frequently give unsatisfactory results in earlier versions.

Jerry

ExcelMonkey < wrote:

Does anyone know how to generate random numbers with lognormal
distributions? I am assuming that I can use the LogInv and LogNormDist
function. But as with the normal distributions, I would assume that
this would be slow. Does anyone know of a VBA sub that generates
random numbers lognormally.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Log Normal Distribution

Option Explicit

Function rsNORMAL(Optional ByVal rsMean, Optional ByVal rsSD, _
Optional rsMin, Optional rsMax)
'Generates random normal variable.
Dim a As Double
With Application
a = Sin(2 * .Pi() * Rnd()) * (-2 * Log(Rnd())) ^ 0.5
If Not IsMissing(rsSD) And Not IsMissing(rsMean) Then
a = a * rsSD + rsMean
End If
If Not IsMissing(rsMin) And Not IsMissing(rsMax) Then
a = .Min(rsMax, .Max(rsMin, a))
End If
End With
rsNORMAL = a
a = vbEmpty
End Function

Function rsLOGNORMAL(Optional ByVal rsMean, Optional ByVal rsSD, _
Optional rsMin, Optional rsMax)
'Generates random lognormal variable.
Dim a As Double
If Not IsMissing(rsSD) And Not IsMissing(rsMean) Then
rsSD = (Log((rsSD / rsMean) ^ 2 + 1)) ^ 0.5
rsMean = Log(rsMean) - rsSD ^ 2 / 2
a = Exp(rsSD * rsNORMAL() + rsMean)
Else
a = Exp(rsNORMAL())
End If
If Not IsMissing(rsMin) And Not IsMissing(rsMax) Then
With Application
a = .Min(rsMax, .Max(rsMin, a))
End With
End If
rsLOGNORMAL = a
a = vbEmpty
End Functio

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Log Normal Distribution

Thanks guys


---
Message posted from http://www.ExcelForum.com/

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
normal distribution chart Rene Charts and Charting in Excel 2 July 5th 09 07:18 PM
Normal distribution Alexandra Lopes Excel Worksheet Functions 2 December 4th 08 02:36 PM
Normal Distribution line oz_orlando Excel Discussion (Misc queries) 0 January 31st 06 06:07 PM
NORMAL DISTRIBUTION FLKULCHAR Excel Worksheet Functions 13 October 27th 05 10:35 PM
Normal Distribution? Anthony Slater Excel Discussion (Misc queries) 2 March 8th 05 07:21 PM


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

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

About Us

"It's about Microsoft Excel"