Skip to content

Instantly share code, notes, and snippets.

@oerpli
Created June 3, 2014 17:38
Show Gist options
  • Save oerpli/9a8752b630126e33ad85 to your computer and use it in GitHub Desktop.
Save oerpli/9a8752b630126e33ad85 to your computer and use it in GitHub Desktop.
private int kinmc(int endtime, double eps) {
double m = 10;
double c = 0.01;
double time = 0;
int state = 0, nstate = 0;
double r01 = c * m;
double r02 = c;
double r1 = Math.Exp(-eps / 2);
double r2 = Math.Exp(-eps);
double[] rtot = { r01 + r02, r1, r2 };
double[] swtime = new double[3];
while(time <= endtime) {
state = nstate;
if(state == 0)
nstate = rng.NextDouble() * rtot[state] > r01 ? 2 : 1;
else
nstate = 0;
time += expverteilung(rtot[state]);
}
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment