I would like to define binomial distribution function in pgfplots. I my MWE
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
[
declare function = {
binom(\n, \k) = \n! / \k! / (\n - \k)!;
binompdf(\n, \p, \k) = binom(\n, \k) * \p^\k * (1 - \p)^(\n - \k);
% binomcdf(\n, \p, \k) = sum(\i = 1 ... \k, binompdf(\n, \p, \i));
}
]
\begin{axis}
[
grid = none,
tick style = {black},
tick label style = {
/pgf/number format/use comma,
/pgf/number format/fixed,
/pgf/number format/fixed zerofill},
scaled ticks = false,
% x axis
xmin = 0, xmax = 0.01,
axis x line = middle, x axis line style = -{Stealth},
xlabel = $p$, xlabel style = {below},
xtick = {0, 0.001, ..., 0.01}, xticklabels = {},
extra x ticks = {0.001},
xticklabel style = {/pgf/number format/precision = 3},
% y axis
ymin = 0, ymax = 1.1,
axis y line = middle, y axis line style = -{Stealth},
ylabel = $P(X \ge 10)$, ylabel style = {left},
ytick = {0, 0.1, ..., 1.1}, yticklabels = {},
extra y ticks = {0.1},
]
\addplot[domain = 0 : 0.01, samples = 1000] {0.8};
\addplot[domain = 0 : 0.01, samples = 1000] {1 - binompdf(2100, x, 0)};
\end{axis}
\end{tikzpicture}
\end{document}
the declation of binompdf() is recognized by the \addplot command. What is the reason for this?
Note: The ultimate goal is to write a function for the cumulative binomial distribution. For now, the y axis label does not correspond to the function that is plotted.
