 !default couleur= red
 !goto $i
 
 :binomial
hist=!values binomial($parm1,x)\
*$parm2^x*(1-$parm2)^($parm1-x)  for x =0 to $parm1
 val=!values x for x=0 to $parm1
size_$i=$[min(1000,max(50*$parm1,200))]
!goto end 
!exit

 :geometric
 hist=!values   $parm1*(1-$parm1)^x for x =0 to 20 
val=!values x for x=0 to 20
size_$i=800
!goto end
!exit

:pascal
hist=!values binomial(x-1,$parm1-1)\
*$parm2^($parm1)*(1-$parm2)^(x-$parm1) for x =$parm1 to 3*$parm1
val=!values x for x=$parm1 to 3*$parm1
size_$i=$[min(1000,max(50*$parm1,200))]
!goto end
!exit

:hypergeometric
b= $[binomial($parm1,$parm3)^(-1)]
min= $[max(0,$parm3+$parm2-$parm1)]
max= $[min($parm3,$parm1)]
hist=!values binomial($parm2,x)*binomial($parm1-$parm2,$parm3-x)*$b for x=$min to $max
val=!values x for x=$min to $max
size_$i=$[min(1000,max(100*($max-$min),200))]
!goto end
!exit

:poisson
hist=!values $[exp(-$parm1)] * $parm1^x/factorial(x) for x=0 to 20 
val=!values x for x=0 to 20
size_$i=800
!goto end
!exit

:end

!read slib/stat/histo [$hist] ,[$val],noxtics,noytics,baton,color $couleur
hist_$i=$slib_out
!exit

:chi2
u= !exec pari gamma($parm1*0.5)^(-1)
f=0.5*exp(-0.5*t)*(0.5*t)^($parm1/2-1)*$u 
!read slib/function/bounds $f,t, 0, 3*$parm1
rangey=!item 2 of $slib_out
par=$[$rangey/20]
hist_$i=xrange -1, $[3*$parm1]\
yrange -0.1,$rangey*1.1\
hline 0,0,black\
vline 0,0,black\
trange 0,3*$parm1\
plot $couleur,  t,$f

size_$i=300

!exit

:cauchy
cst= $[(pi*$parm2)^(-1)]
hist_$i=xrange -$[ 2*abs($parm1)], $[2*abs($parm1)]\
yrange -0.5,1.2\
hline 0,0,black\
vline 0,0,black\
plot $couleur,$cst/(1+((x-$parm1)/$parm2)^2)
size_$i=300

!exit

:exponential
hist_$i=xrange -1, $[3*$parm1]\
yrange -0.5,1.2\
hline 0,0,black\
vline 0,0,black\
trange 0,3*$parm1\
plot $couleur,t, $parm1 *exp(-$parm1*t)

size_$i=300

!exit
:gamma
u=!exec pari gamma($parm1)^(-1)
f=$parm2*exp(-$parm2*t)*($parm2*t)^($parm1-1)*$u
!read slib/function/bounds $f,t, 0, 3*$parm1
rangey=!item 2 of $slib_out
par=$[$rangey/10]
hist_$i=xrange -1, $[3*$parm1]\
yrange -0.5,$rangey\
hline 0,0,black\
vline 0,0,black\
trange 0,3*$parm1\
plot $couleur,t, $parm2*exp(-$parm2*t)*($parm2*t)^($parm1-1)*$u
size_$i=300

!exit

:laplace
hist_$i=xrange -4,4\
yrange -0.5,1.2\
hline 0,0,black\
vline 0,0,black\
trange -2,2\
plot $couleur, t,exp (- abs (t)) / 2
size_$i=300
!exit

:logistic
hist_$i=xrange -3, 3\
yrange -0.5,1.2\
hline 0,0,black\
vline 0,0,black\
plot $couleur, 1/(1+exp(-x))^2*exp(-x)

size_$i=300
!exit

:lognormal
hist_$i=xrange -1, $[3*$parm1]\
yrange -0.5,1.2\
hline 0,0,black\
vline 0,0,black\
trange 0,$parm1\
plot $couleur, t, exp(-(log(t/$parm1))^2/(2*$parm2^2))/(t*$parm2*(2*pi)^0.5)

size_$i=300
!exit

:normal
hist_$i=xrange $[$parm1-2*$parm2],$[$parm1+2*$parm2]\
yrange -0.5,1.1\
hline 0,0,black\
vline 0,0,black\
text black , 0,1,medium,1\
text black , $parm1,0,medium,$parm1\
line  $parm1,-0.05,$parm1,0.05,blue\
plot $couleur, exp(-(x-$parm1)^2/(2*$parm2^2))/((2*pi)^(1/2)*$parm2)

size_$i=300
!exit

:weibull
f=$parm1*$parm2*exp(-$parm2*t^($parm1))*t^($parm1-1)
!read slib/function/bounds $f,t, 0, 3*$parm1
rangey=!item 2 of $slib_out
par=$[$rangey/10]
hist_$i=xrange -1, $[3*$parm1]\
yrange -0.5,$rangey\
hline 0,0,black\
vline 0,0,black\
trange 0,3*$parm1\
plot $couleur,t,$parm1*$parm2*exp(-$parm2*t^($parm1))*t^($parm1-1) 
size_$i=200
!exit

:student
cte=!exec pari gamma(($parm1+1)/2)/(sqrt($parm1*pi)*gamma($parm1/2))

f=$cte*(1+x^2/$parm1)^(-$[($parm1+1)/2])
!read slib/function/bounds $f, -3, 3
rangey=!item 2 of $slib_out
par=$[$rangey/10]
hist_$i=xrange -3, 3\
yrange -0.5,$rangey\
hline 0,0,black\
vline 0,0,black\
plot $couleur,$f

size_$i=300
!exit

:fisher
cst=!exec pari $parm1^($parm1/2)*$parm2^($parm2/2)*gamma(($parm1+$parm2)/2)/(gamma($parm1/2)*gamma($parm2/2))
f=$cst*t^(-1+$parm1/2)*($parm2+$parm1*t)^(-($parm1+$parm2)/2)

!read slib/function/bounds $f,t, 0,5
rangey=!item 2 of $slib_out
par=$[$rangey/10]
hist_$i=xrange -0.1, 5\
yrange -0.3,$rangey\
hline 0,0,black\
vline 0,0,black\
trange 0,5\
plot $couleur,t,$f 

size_$i=300
!exit

:beta
cte=!exec pari gamma($parm1+$parm2)/(gamma($parm1)*gamma($parm2))
 f=$cte*t^($[$parm1-1])* (1-t)^($[$parm2-1])
 
!read slib/function/bounds $f,t, 0,1
rangey=!item 2 of $slib_out
par=$[$rangey/10]
hist_$i=xrange -0.1, 1.1\
yrange -0.5,$rangey\
hline 0,0,black\
vline 0,0,black\
trange 0,1\
plot $couleur,t,$f 

size_$i=300
!exit


size_$i=300
!exit




