Hello!
I want to simulate a process using the poisson distribution. If the poisson distributed event occurs I want a variable to show "1" else "0".
Can you help me? did you understand?![]()
Hello!
I want to simulate a process using the poisson distribution. If the poisson distributed event occurs I want a variable to show "1" else "0".
Can you help me? did you understand?![]()
Hi,
Take a look at
http://support.microsoft.com/kb/828130
HTH
Welcome to the forum.
You want a function that generates random variates with Poisson distribution?
Last edited by shg; 03-09-2010 at 12:01 PM.
Entia non sunt multiplicanda sine necessitate
I am trying to model a stock price simulation with jumps (jump diffusion process). I want the variable to show "1" if the jump occurs. The jump is poisson distributed and can occur more than once in my interval (250 days), I would like to have the ability to adjust the frequency (lambda) of the jumps.
yes, I want a function which generate variates with poisson distribution.
![]()
Function RandPois(Lambda As Single, _ Optional bVolatile As Boolean = False) As Long ' shg 2007 ' UDF or VBA ' Returns a random Poisson variate with variance Lambda ' Knuth, Seminumerical Algorithms, p 132 Dim L As Single Dim k As Long Dim p As Single If bVolatile Then Application.Volatile L = Exp(-Lambda) p = 1 Do k = k + 1 p = p * Rnd Loop Until p <= L RandPois = k - 1 End Function
Perfect! Thank you.
If I want to "resimulate" my model by hitting f9, the VBAscript won't update. Do you have a sollution to this as well?
never mind![]()
Well, actually - please do mind
=RandPois(some number, TRUE)
Thank you!
Do you have the coding for repeating the simulation for instance 1000 times, and writing the values to a new cell each time?
![]()
Dim lambda As Double lambda = 2.7 With Range("A1:A1000") .Formula = "=RandPois(" & lambda & ")" .Value = .Value End With
Last edited by shg; 03-15-2010 at 01:45 PM.
Sorry, I wasn't clear enough.
Each time I enter F9 I get six generated outcomes.
I want to do this simulation 1000 times and write the result to a new cell.
Thanks for all your help!
You're not being any clearer now. I have no idea what your workbook looks like.
Ok, each time enter F9 I get a result in 6 cells,
I want a macro who takes the results and copy them to a spreadsheet, then runs a new simulation and copies the results to the row underneath the results from the previous simulation.
I try to use function RandPois in excel 2007, but it cannot be recognized by excel. Does 2007 have different syntax for the function?
sorry...
copy the results from the simulation which is done when I press F9. To a new spreadsheet in the same document.
I want this to be repeated 1000 times, and for each time copied the results one row below the previous the results.
the clue is that I want to run a simulation 1000 times and save all the results.
![]()
Sub x() Dim i As Long Sheet2.Cells.ClearContents Application.ScreenUpdating = False For i = 1 To 1000 Sheet1.Calculate Sheet1.Range("A1:A6").Copy Sheet2.Cells(Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues Next i Application.ScreenUpdating = True End Sub
youre good.
thx
It has occured a new problem...
My sheet regenerates new variables between each time something is done in the sheet. How can I avvoid this, and make it only generate new variables with the calculatefunction in VBA
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks