Skip to content

Instantly share code, notes, and snippets.

@sumtxt
Created June 25, 2013 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumtxt/5856688 to your computer and use it in GitHub Desktop.
Save sumtxt/5856688 to your computer and use it in GitHub Desktop.
Animated Beta Distribution beta(x,2,0:7) with gnuplot.
Binv(p,q)=exp(lgamma(p+q)-lgamma(p)-lgamma(q))
beta(x,p,q)=p<=0||q<=0?1/0:x<0||x>1?0.0:Binv(p,q)*x**(p-1.0)*(1.0-x)**(q-1.0)
ymax = 3.2
xmin = 0.0
xmax = 1.0
set term gif animate delay 4
set output "betapdf.gif"
set zeroaxis
set xrange [xmin : xmax]
set yrange [0 : ymax]
set xlabel "x"
set ylabel "p(x)"
set xtics autofreq
set ytics autofreq
set format x "%.1f"
set format y "%.1f"
set title "Beta PDF"
plot beta(x, 2, 0.1 )
plot beta(x, 2, 0.2 )
plot beta(x, 2, 0.3 )
plot beta(x, 2, 0.4 )
plot beta(x, 2, 0.5 )
plot beta(x, 2, 0.6 )
plot beta(x, 2, 0.7 )
plot beta(x, 2, 0.8 )
plot beta(x, 2, 0.9 )
plot beta(x, 2, 1 )
plot beta(x, 2, 1.1 )
plot beta(x, 2, 1.2 )
plot beta(x, 2, 1.3 )
plot beta(x, 2, 1.4 )
plot beta(x, 2, 1.5 )
plot beta(x, 2, 1.6 )
plot beta(x, 2, 1.7 )
plot beta(x, 2, 1.8 )
plot beta(x, 2, 1.9 )
plot beta(x, 2, 2 )
plot beta(x, 2, 2.1 )
plot beta(x, 2, 2.2 )
plot beta(x, 2, 2.3 )
plot beta(x, 2, 2.4 )
plot beta(x, 2, 2.5 )
plot beta(x, 2, 2.6 )
plot beta(x, 2, 2.7 )
plot beta(x, 2, 2.8 )
plot beta(x, 2, 2.9 )
plot beta(x, 2, 3 )
plot beta(x, 2, 3.1 )
plot beta(x, 2, 3.2 )
plot beta(x, 2, 3.3 )
plot beta(x, 2, 3.4 )
plot beta(x, 2, 3.5 )
plot beta(x, 2, 3.6 )
plot beta(x, 2, 3.7 )
plot beta(x, 2, 3.8 )
plot beta(x, 2, 3.9 )
plot beta(x, 2, 4 )
plot beta(x, 2, 4.1 )
plot beta(x, 2, 4.2 )
plot beta(x, 2, 4.3 )
plot beta(x, 2, 4.4 )
plot beta(x, 2, 4.5 )
plot beta(x, 2, 4.6 )
plot beta(x, 2, 4.7 )
plot beta(x, 2, 4.8 )
plot beta(x, 2, 4.9 )
plot beta(x, 2, 5 )
plot beta(x, 2, 5.1 )
plot beta(x, 2, 5.2 )
plot beta(x, 2, 5.3 )
plot beta(x, 2, 5.4 )
plot beta(x, 2, 5.5 )
plot beta(x, 2, 5.6 )
plot beta(x, 2, 5.7 )
plot beta(x, 2, 5.8 )
plot beta(x, 2, 5.9 )
plot beta(x, 2, 6 )
plot beta(x, 2, 6.1 )
plot beta(x, 2, 6.2 )
plot beta(x, 2, 6.3 )
plot beta(x, 2, 6.4 )
plot beta(x, 2, 6.5 )
plot beta(x, 2, 6.6 )
plot beta(x, 2, 6.7 )
plot beta(x, 2, 6.8 )
plot beta(x, 2, 6.9 )
set output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment