Added MACS source
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / doc / randplots.gnp
1 #set term postscript eps enhanced
2 set term pstex monochrome
3 set samples 300
4 #set size 0.8,0.88  # paperback 6x9  #CHANGE THESE LATER IN FILE ALSO 
5 set size 1,1.1      # us letter      #IF MODIFIED 
6 set border 31 lw 0.5
7 set tics out
8 set ticscale 0.5 0.25
9 set xtics border nomirror norotate
10 set ytics border nomirror norotate
11 set format x "%g"
12
13 # Continuous distributions
14
15 set xlabel "$x$"
16 set ylabel "$p(x)$"
17
18 set xrange [-5:5]
19 set yrange [0:0.5]
20 set ytics 0.1
21 set xtics 1
22 set output "rand-gaussian.tex"
23 set title "Gaussian Distribution"
24 p(x)=1/sqrt(2*pi*sigma**2)*exp(-x**2/(2*sigma**2))
25 plot sigma=1.0, p(x) title "$\\sigma=1$", \
26         sigma=2.0, p(x) title "$\\sigma=2$"
27
28 set xrange [0:5]
29 set yrange [0:2]
30 set ytics 0.5
31 set xtics 1
32 set output "rand-gaussian-tail.tex"
33 set title "Gaussian Tail Distribution"
34 p(x)= x > a ? 1/(0.5*erfc(a/sqrt(2*sigma**2))*sqrt(2*pi*sigma**2))*exp(-x**2/(2*sigma**2)) : 0
35 plot a=1.5, sigma=1.0, p(x) title "$\\sigma=1,a=1.5$"
36
37 set xrange [0:5]
38 set yrange [0:1.09]
39 set ytics 0.5
40 set xtics 1
41 set output "rand-rayleigh-tail.tex"
42 set title "Rayleigh Tail Distribution"
43 p(x)= x > a ? (x/sigma**2)*exp((a**2 - x**2)/(2*sigma**2)) : 0
44 plot a=1.0, sigma=1.0, p(x) title "$a=1,\\sigma=1$", \
45         a=0.5, sigma=2.0, p(x) title "$a=0.5,\\sigma=2$"
46
47 set size ratio -1 0.8,1.143
48 set xlabel "$x$"
49 set ylabel "$y$"
50 set xrange [-2:2]
51 set yrange [-2:2]
52 set ytics 1
53 set xtics 1
54 set output "rand-bivariate-gaussian.tex"
55 set title "Bivariate Gaussian Distribution"
56 set isosamples 30
57 p(x,y)=1/sqrt(2*pi*sqrt(1-rho**2))*exp(-(x**2 + y**2 - 2*rho*x*y)/(2*(1-rho**2)))
58 #set cntrparam cspline
59 set noclabel
60 set contour
61 set view 0,0
62 set nosurface
63 splot rho=0.9, p(x,y) title "$\\sigma_x=1, \\sigma_y=1, \\rho=0.9$"
64 set size noratio 1,1.1  # us letter
65
66 set xlabel "$x$"
67 set ylabel "$p(x)$"
68 set ytics 0.1
69 set xrange [-5:5]
70 set yrange [0:0.4]
71 set output "rand-cauchy.tex"
72 set title "Cauchy Distribution"
73 p(x)=1/(pi*a*(1+(x/a)**2))
74 plot a=1.0, p(x) title "$a=1$", \
75         a=2.0, p(x) title "$a=2$"
76
77 set ytics 0.5
78 set yrange [0:1]
79 set xrange [0:3]
80 set output "rand-exponential.tex"
81 set title "Exponential Distribution"
82 p(x)=exp(-x/mu)/mu
83 plot mu=1.0, p(x) title "$\\mu=1$", \
84         mu=2.0, p(x) title "$\\mu=2$"
85
86 set yrange [0:1]
87 set xrange [0:3]
88 set output "rand-chisq.tex"
89 set title "Chi-squared Distribution"
90 p(x)=(x/2)**(nu/2.0-1.0) *exp(-x/2)/ (2*gamma(nu/2.0))
91 plot nu=1.0, p(x) title "$\\nu=1$", \
92       nu=2.0, p(x) title "$\\nu=2$", \
93         nu=3.0, p(x) title "$\\nu=3$"
94
95 set yrange [0:1]
96 set xrange [0:5]
97 set output "rand-erlang.tex"
98 set title "Erlang Distribution"
99 p(x)=x**(n-1) *exp(-x/a)/ (gamma(n)*a**n)
100 plot n=1.0, a=1, p(x) title "$n=1$", \
101       n=2.0, a=1.0, p(x) title "$n=2$", \
102         n=3.0, a=1.0, p(x) title "$n=3$"
103
104 set xrange [0:2]
105 set xtics 1
106 set output "rand-fdist.tex"
107 set title "F-Distribution"
108 p(x)=gamma((v1+v2)/2.0)*v1**(v1/2.0)*v2**(v2/2.0)\
109         /gamma(v1/2.0)/gamma(v2/2.0) * \
110         x**(v1/2.0-1)*(v2+v1*x)**-(v1/2.0+v2/2.0)
111 plot v1=1.0, v2=1.0, p(x) title "$\\nu_1=1, \\nu_2=1$", \
112       v1=3.0, v2=1.0, p(x) title "$\\nu_1=3, \\nu_2=2$"
113
114 set xrange [0:5]
115 set output "rand-flat.tex"
116 set title "Flat Distribution"
117 p(x)= (x<b && x>a) ? 1/(b-a) : 0
118 plot a=0.5, b=2.5, p(x) title "$a=0.5,b=2.5$" with step, \
119       a=1.2, b=4.8, p(x) title "$a=1.2,b=4.8$" with step
120
121 set xrange [0:5]
122 set yrange [0:1]
123 set ytics 0.5
124 set output "rand-gamma.tex"
125 set title "Gamma Distribution"
126 p(x)= x**(a-1)* exp(-x) / gamma(a)
127 plot a=1.0, p(x) title "$a=1$", \
128       a=2.0, p(x) title "$a=2$", \
129       a=3.0, p(x) title "$a=3$"
130
131 set xrange [0:1]
132 set yrange [0:4]
133 set xtics 0.25
134 set ytics 1
135 set output "rand-beta.tex"
136 set title "Beta Distribution"
137 p(x)= gamma(a+b)/(gamma(a)*gamma(b))*x**(a-1)*(1-x)**(b-1)
138 plot a=2.0, b=2.0, p(x) title "$a=2,b=2$", \
139       a=4.0, b=1.0, p(x) title "$a=4,b=1$", \
140       a=1.0, b=4.0, p(x) title "$a=1,b=4$"
141
142
143 set xrange [-5:5]
144 set yrange [0:0.3]
145 set ytics 0.1
146 set xtics 1
147 set output "rand-logistic.tex"
148 set title "Logistic Distribution"
149 p(x)= exp(-x/a)/a/(1+exp(-x/a))**2
150 plot a=1.0, p(x) title "$a=1$", \
151         a=2.0, p(x) title "$a=2$"
152
153 set xrange [0:3]
154 set yrange [0:0.7]
155 set xtics 1
156 set ytics 0.5
157 set output "rand-lognormal.tex"
158 set title "Lognormal Distribution"
159 p(x)= exp(-(log(x)-zeta)**2/2/sigma**2)/sqrt(2*pi*sigma**2)/x
160 plot zeta=0.0, sigma=1.0, p(x) title "$\\zeta=0, \\sigma=1$", \
161         zeta=1.0, sigma=1.0, p(x) title "$\\zeta=1, \\sigma=1$"
162
163 set xrange [0:5]
164 set yrange [0:2]
165 set ytics 0.5
166 set xtics 1
167 set output "rand-pareto.tex"
168 set title "Pareto Distribution"
169 p(x)= x>b ? a*b**a/x**(a+1) : 0
170 plot a=1.0, b=1, p(x) title "$a=1, b=1$", \
171         a=3.0, b=2, p(x) title "$a=3, b=2 $"
172
173 set xrange [0:5]
174 set yrange [0:0.7]
175 set ytics 0.1
176 set xtics 1
177 set output "rand-rayleigh.tex"
178 set title "Rayleigh Distribution"
179 p(x)= (x/sigma**2)*exp(-x**2/(2*sigma**2))
180 plot sigma=1.0, p(x) title "$\\sigma=1$", \
181         sigma=2.0, p(x) title "$\\sigma=2$"
182
183 set xrange [0:5]
184 set yrange [0:1.09]
185 set ytics 0.5
186 set xtics 1
187 set output "rand-rayleigh-tail.tex"
188 set title "Rayleigh Tail Distribution"
189 p(x)= x > a ? (x/sigma**2)*exp((a**2 - x**2)/(2*sigma**2)) : 0
190 plot a=1.0, sigma=1.0, p(x) title "$a=1,\\sigma=1$", \
191         a=0.5, sigma=2.0, p(x) title "$a=0.5,\\sigma=2$"
192
193 set xrange [-4:4]
194 set yrange [0:0.5]
195 set ytics 0.1
196 set output "rand-tdist.tex"
197 set title "Student's t distribution"
198 p(x)=gamma((v+1.0)/2)/sqrt(pi*v)/gamma(v/2)*(1+(x**2)/v)**-((v+1.0)/2)
199 plot v=1.0, p(x) title "$\\nu_1=1$", \
200       v=5.0, p(x) title "$\\nu_1=5$"
201
202 set xrange [-5:5]
203 set yrange [0:0.55]
204 set ytics 0.1
205 set output "rand-laplace.tex"
206 set title "Laplace Distribution (Two-sided Exponential)"
207 p(x)=exp(-abs(x)/a)/2/a
208 plot a=1.0, p(x) title "$a=1$", \
209         a=2.0, p(x) title "$a=2$"
210
211 set xrange [-5:5]
212 set yrange [0:0.8]
213 set ytics 0.2
214 set output "rand-exppow.tex"
215 set title "Exponential Power Distribution"
216 p(x)=exp(-(abs(x/a))**b)/2/a/gamma(1.0+1.0/b)
217 plot a=1.0, b=2.5, p(x) title "$a=1, b=2.5$", \
218         a=1.0, b=0.5, p(x) title "$a=1, b=0.5$"
219
220 set xrange [-5:10]
221 set yrange [0:0.2]
222 set ytics 0.1
223 set output "rand-landau.tex"
224 set title "Landau Distribution"
225 plot 'landau.dat' notitle w lines
226
227 set xrange [-5:5]
228 set yrange [0:0.45]
229 set ytics 0.1
230 set output "rand-levy.tex"
231 set title "Levy Distribution"
232 p1(x)=1/(pi*mu*(1+(x/mu)**2))
233 p2(x)=1/sqrt(2*pi*2*mu**2)*exp(-x**2/(4*mu**2)) 
234 plot mu=1.0, a=1, p1(x) title "$c=1, \\alpha=1.0$", \
235         mu=1.0, a=2, p2(x) title "$c=1, \\alpha=2.0$"
236
237 set xrange [-5:5]
238 set yrange [0:0.09]
239 set ytics 0.05
240 set output "rand-levyskew.tex"
241 set title "Levy Skew Distribution"
242 logp(x)= 1.0990e+01+x*(-3.3388e-01+x*(-4.2372e-01+x*(2.1749e-01+x*(-4.4910e-02 + x*(4.1801e-03 - 1.4456e-04*x)))))
243 p1(x)=exp(logp(x))/1000000
244 plot mu=1.0, a=1, p1(x) title "$c=1, \\alpha=1.0, \\beta=1.0$"
245
246
247 set xrange [0:2]
248 set yrange [0:1.5]
249 set ytics 0.5
250 set xtics 0.5
251 set output "rand-weibull.tex"
252 set title "Weibull Distribution"
253 p(x)=(b/a) * (x/a)**(b-1) * exp(-(x/a)**b)
254 plot a=1.0, b=1.0, p(x) title "$a=1,b=1$", \
255        a=1.0, b=2.0, p(x) title "$a=1,b=2$", \
256          a=2.0, b=3.0, p(x) title "$a=2,b=3$"
257
258 set xrange [-2:5]
259 set yrange [0:0.5]
260 set ytics 0.1
261 set xtics 1.0
262 set output "rand-gumbel1.tex"
263 set title "Type 1 Gumbel Distribution"
264 p1(x)=a*b*exp(-(b*exp(-a*x)+a*x))
265 plot a=1.0, b=1.0, p1(x) title "Type 1, $a=1,b=1$"
266
267 set xrange [0:2]
268 set yrange [0:0.7]
269 set ytics 0.1
270 set xtics 0.5
271 set output "rand-gumbel2.tex"
272 set title "Type 2 Gumbel Distribution"
273 p2(x)=x > 0 ? a*b*x**(-a-1)*exp(-b*x**-a) : 0
274 plot a=1.0, b=1.0, p2(x) title "Type 2, $a=1,b=1$"
275
276 # Discrete distributions
277
278 set xlabel "$k$"
279 set ylabel "$p(k)$"
280 set ticscale 0.5 1
281 set mxtics 2
282
283 set xrange [-0.5:10.5]
284 set yrange [0:0.3]
285 set ytics 0.1
286 set xtics 1
287 set function style step
288 set output "rand-poisson.tex"
289 set title "Poisson Distribution"
290 p(x)=mu**int(x)/(int(x)!) * exp(-mu)
291 plot mu=2.5, p(x+0.5) title "$\\mu=2.5$"
292
293 set xrange [:1.5]
294 set yrange [0:1]
295 set ytics 0.5
296 set xtics 1
297 set function style step
298 set output "rand-bernoulli.tex"
299 set title "Bernoulli Trial"
300 p(x)= (int(x) == 0) ? 1-p : p
301 plot p = 0.7, p(x+0.5) title "$p=0.7$"
302
303 set xrange [:10.5]
304 set yrange [0:0.3]
305 set xtics 1
306 set ytics 0.1
307 set output "rand-binomial.tex"
308 set title "Binomial Distribution"
309 p(x)= P**int(x)*(1-P)**(n-int(x))*gamma(n+1.0)/gamma(int(x)+1.0)/gamma(n-int(x)+1.0) + 1e-5
310 plot P=0.5,n=9.99999999, p(x+0.5) title "$p=0.5,n=9$"
311
312 set xrange [:5.5]
313 set yrange [0:0.7]
314 set ytics 0.1
315 set xtics 1
316 set output "rand-geometric.tex"
317 set title "Geometric Distribution"
318 p(x)=int(x) ? P*(1-P)**int(x-1) : 0
319 plot P=0.5, p(x+0.5) title "$p=0.5$"
320
321 set xrange [:10.5]
322 set yrange [0:0.7]
323 set ytics 0.1
324 set xtics 1
325 set output "rand-logarithmic.tex"
326 set title "Logarithmic Distribution"
327 p(x)=int(x) ? (-1/log(1-P))*(P**int(x))/int(x) : 0
328 plot P=0.7, p(x+0.5) title "$p=0.7$"
329
330 set xrange [:10.5]
331 set yrange [0:0.7]
332 set ytics 0.1
333 set xtics 1
334 set output "rand-hypergeometric.tex"
335 set title "Hypergeometric Distribution"
336 choose(a,b)=gamma(a+1)/(gamma(b+1)*gamma(a-b+1))
337 p(x)=choose(n1,int(x))*choose(n2,t-int(x))/choose(n1+n2,t)
338 plot n1=5, n2=20, t=3, p(x+0.5) title "$n1=5, n2=20, t=3$"
339
340 set xrange [:10.5]
341 set yrange [0:0.3]
342 set xtics 1
343 set ytics 0.1
344 set output "rand-nbinomial.tex"
345 set title "Negative Binomial Distribution"
346 p(x)= (P**n)*((1-P)**(int(x)))*gamma(n+int(x))/gamma(n)/gamma(int(x)+1.0) + 1e-5
347 plot P=0.5,n=3.5, p(x+0.5) title "$p=0.5,n=3.5$"
348
349 set xrange [:10.5]
350 set yrange [0:0.3]
351 set xtics 1
352 set ytics 0.1
353 set output "rand-pascal.tex"
354 set title "Pascal Distribution"
355 p(x)= (P**n)*((1-P)**(int(x)))*gamma(n+int(x))/gamma(n)/gamma(int(x)+1.0) + 1e-5
356 plot P=0.5,n=3, p(x+0.5) title "$p=0.5,n=3$"
357
358 ######################################################################
359
360 set ticscale 1 0
361 set xrange [-5:5]
362 set yrange [-5:5]
363 set xtics 1
364 set ytics 1
365 set size 0.8,1.143
366 set size square
367 set output "random-walk.tex"
368 set title "Random walk"
369 set xzeroaxis
370 set yzeroaxis
371 set nokey
372 plot "rand-walk.dat" using 1:2 with linesp
373
374