+ Reply to Thread
Results 1 to 23 of 23

Poisson distribution - simulation

Hybrid View

Hjahren Poisson distribution -... 03-09-2010, 10:19 AM
JeanRage Re: Poisson distribution -... 03-09-2010, 10:24 AM
shg Re: Poisson distribution -... 03-09-2010, 11:58 AM
Hjahren Re: Poisson distribution -... 03-10-2010, 05:54 AM
Hjahren Re: Poisson distribution -... 03-10-2010, 05:58 AM
Hjahren Re: Poisson distribution -... 03-11-2010, 05:35 AM
Hjahren Re: Poisson distribution -... 03-11-2010, 06:43 AM
Hjahren Re: Poisson distribution -... 03-11-2010, 09:39 AM
shg Re: Poisson distribution -... 03-11-2010, 11:05 AM
Hjahren Re: Poisson distribution -... 03-12-2010, 08:31 AM
Hjahren Re: Poisson distribution -... 03-15-2010, 01:38 PM
shg Re: Poisson distribution -... 03-15-2010, 01:42 PM
Hjahren Re: Poisson distribution -... 03-16-2010, 06:23 AM
shg Re: Poisson distribution -... 03-16-2010, 10:59 AM
npc008 Re: Poisson distribution -... 08-14-2013, 06:12 AM
Hjahren Re: Poisson distribution -... 03-16-2010, 06:50 PM
shg Re: Poisson distribution -... 03-16-2010, 07:00 PM
Hjahren Re: Poisson distribution -... 03-16-2010, 07:23 PM
Hjahren Re: Poisson distribution -... 04-12-2010, 09:00 AM
  1. #1
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Poisson distribution - simulation

    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?

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Poisson distribution - simulation

    Hi,

    Take a look at
    http://support.microsoft.com/kb/828130

    HTH

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

    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

  4. #4
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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.

  5. #5
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    yes, I want a function which generate variates with poisson distribution.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

    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

  7. #7
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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?

  8. #8
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    never mind

  9. #9
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    Well, actually - please do mind

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

    =RandPois(some number, TRUE)

  11. #11
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    Thank you!

  12. #12
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    Do you have the coding for repeating the simulation for instance 1000 times, and writing the values to a new cell each time?

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

        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.

  14. #14
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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!

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

    You're not being any clearer now. I have no idea what your workbook looks like.

  16. #16
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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.

  17. #17
    Registered User
    Join Date
    08-14-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Poisson distribution - 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?

  18. #18
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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.

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Poisson distribution - simulation

    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

  20. #20
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    youre good.

    thx

  21. #21
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: Poisson distribution - simulation

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1