Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Simulating uni-dimensional Hawkes processes

by glrm_master (Initiate)
on Feb 18, 2013 at 19:29 UTC ( [id://1019389]=note: print w/replies, xml ) Need Help??


in reply to Re: Simulating uni-dimensional Hawkes processes
in thread Simulating uni-dimensional Hawkes processes

thanks a lot roboticus for your help: I will look into your changes as soon as I'm done preparing tomorrows exam :((

now, back to your coments: 1)I usually let the loop run for 10,000 or 50,000 iterations to get my arrival times (that I then use in my MLE to get the estimates for lambda0, alpha and beta)... I must have send you a latest version of the code where i was trying to figure out in only 2 iterations what the hack was wrong with my code... but you made a very good point about it!

2)thanks for the advice about how/where to define my variables (including the whole "action at distance issue"): i'll definitely keep that in mind in my codes!

3)I was wondering what was the best way to code an algorith that has an initiation step: thanks for the idea! in my first version of this code I did as you suggested (keeping the initiation out of the loop and than starting the loop from an according index...).. not sure why i decided to go with this way afterwords :(

4)hahaha.. sorry for the mess in the coding!!

I'm not sure I understand why you use the same sequence of random variables: once my algo is initiated, i generate one uniform0,1 in order to get one random variable with an exponential distribution (using the inverse function method) and one uniform0,1 to run an Acceptance/Rejection of sorts (in this case , for stockastic processes is called a "thinning procedure") to decided whether to keep or drop the exponential random variable. However, I haven't had the time yet to run/chane my code with your changes (exam tomorrow keeps me busy) but I will do so ASAP and let you know!!

I really appreciate your help and I will get back to you as soon as i'm done! take care

kris

Replies are listed 'Best First'.
Re^3: Simulating uni-dimensional Hawkes processes
by roboticus (Chancellor) on Feb 18, 2013 at 23:03 UTC

    Regarding your question: Why do I use the same sequence of random variables?

    Well, when I first ran your program a couple of times, I got different results each time. Exactly as you'd expect from a program using some random numbers.

    However, I was playing with the program, I couldn't be certain I haven't broken the code. After all, I wouldn't know what values should come out. So it would be easy for me to introduce an error without noticing it. So I told the program to use the same random numbers each time. That way, I could make a change and run the program. If the output was the same, I probably didn't break it. Then I could move on to the next change. If the output was different, though, I could immediately identify (1) that I introduced an error, and (2) the error was between the last two runs. So I just keep the code in one window, and run the program in another window. That way, I could run the program after each significant change.

    It may be helpful to you for debugging to use the same sequence of random numbers: You could play along by hand with a calculator and verify that the numbers are working the way you want them to. If you find an error, you can correct it, and then run it again and verify that the correction did what you wanted, without having to kill your fingers and your calculator by starting over with a new set of numbers....

    Of course, once you get the code working, you switch back to normal random numbers.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1019389]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found