-
Notifications
You must be signed in to change notification settings - Fork 0
/
gauss_chain
executable file
·53 lines (52 loc) · 976 Bytes
/
gauss_chain
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/awk -f
BEGIN{
if (nr=="")
{
nr=100000;
print "#Setting nr to",nr,"(use option \"-v nr=X\" to change)";
}
else
{
print "#Using nr",nr;
}
if (tau=="")
if (rho=="")
{
rho=0.9;
tau=0.5*(1+rho)/(1-rho);
print "#Setting rho to",rho,"(use option \"-v rho=X\" to change) -> tau_int=",tau;
}
else
{
tau=0.5*(1+rho)/(1-rho);
print "#Using rho -> tau_int=",tau;
}
else
{
rho=(2*tau-1)/(2*tau+1);
tau=0.5*(1+rho)/(1-rho);
print "#Setting rho to",rho,"(use option \"-v rho=X\" to change) -> tau_int=",tau;
}
if (seed=="")
{
print "#Using time as seed (use option \"-v seed=X\" to change)";
srand();
}
else
{
print "#Using ",seed," as seed";
srand(seed);
}
e=0;
pi=3.1415926535;
print "#Output format: timeseries";
for (i=0;i<nr;i++)
{
r=sqrt(-2*log(1-rand()));
phi=2*pi*rand();
gauss_number=r*sin(phi);
e=rho*e+sqrt(1-rho*rho)*gauss_number;
print e;
}
}
#fs md5sum b64ee8a8e79ee9ed1e1e1c09d7b703c6