binomcalc.pl -- extreme precision binomial calculator
by Dave Burton (version 90, 23-May-2021)
Note: you can rename this program to binomcalc.cgi and use it from a web page, via a
"server-side include," as in this example:
That does the same calculation as this command:
c:\> perl -f binomcalc.pl n=12 k=3 p=1/2
The following command-line parameters are supported:
n={integer} (REQUIRED: the n of 'n choose k')
k={integer} (REQUIRED: the k of 'n choose k')
p={probability} (decimal value 0..1, e.g., 0.5, or a fraction, e.g., 1/3)
m={b, cu, acu, co} (b = binomial probability, cu = cumulative probabilities,
acu = all cumulative probabilities, co = coefficient only)
a={q, s, h, x, xx} (q = quick/scalar = default, s is slower w/ extreme precision,
h = hybrid, x and xx are experimental [don't use them])
o={h, t, p} (output: h = html, t = text, p = , default determined by context)
t=nnn (timeout limit, nnn seconds; default = 0 for no timeout)
b=1 (benchmark it; show timings)
d={integer} (digits of accuracy: default for a=s is 500; for a=q it's about 13)
v={integer} (verbosity; 0 = no debug prints, 1 = some, 2 = lots)
Other notes:
1. Default mode is m=b (calculate binomial probability).
2. Default accuracy setting is a=q, which is fastest. For higher accuracy use a=s.
The x and xx (experimental) settings are usually slower and not as good.