Hier nochmal die LuaTeX Antwort, aber komplett in LaTeX. Benötigt `expl3` und somit e-TeX.
\documentclass{article}
\usepackage{xparse}
\usepackage{amsmath}
\usepackage{diagbox}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{siunitx}
\ExplSyntaxOn
\cs_new:Npn \int_factorial:n #1
% computes #1!
{
\int_compare:nTF { (#1) == 0 }
{ 1 }
{ \int_eval:n { (#1) * \int_factorial:n { ((#1) - 1) } } }
}
\cs_new:Npn \int_choose:nn #1#2
% computes (#1 \choose #2)
{
\int_eval:n { \int_factorial:n { #1 } /
( \int_factorial:n { #2 } * \int_factorial:n { #1-#2 } )
}
}
\cs_new:Npn \int_pow:nn #1#2
% computes #1^#2
{
\int_compare:nTF { (#2) == 0 }
{ 1 }
{ \int_eval:n { 1 \prg_replicate:nn { #2 } { * #1 } } }
}
\cs_new_protected:Npn \cis_sum:nnn #1#2#3
% p = #1, n = #2, k = #3
{
\fp_zero:N \l_tmpa_fp
\int_step_inline:nnnn { 0 } { 1 } { #3 }
{
\fp_add:Nn \l_tmpa_fp
{
\int_choose:nn { #2 } { ##1 }
* (#1)^(##1) * (1 - #1)^(#2 - ##1)
}
}
\num{\fp_use:N \l_tmpa_fp}
}
\fp_gzero_new:N \g__cis_p_fp
\int_gzero_new:N \g__cis_k_int
\int_gzero_new:N \g__cis_n_int
\cs_new_protected:Npn \cis_make_table:
{
\int_step_function:nnnN { 5 } { 5 } { 10 } \cis_table_nloop:n
}
\cs_new_protected:Npn \cis_table_nloop:n #1
{
\int_gset:Nn \g__cis_n_int { #1 }
\int_use:N \g__cis_n_int
\int_step_function:nnnN { 0 } { 1 } { #1 } \cis_table_kloop:n
}
\cs_new_protected:Npn \cis_table_kloop:n #1
{
\int_gset:Nn \g__cis_k_int { #1 }
& \int_use:N \g__cis_k_int
\fp_gzero:N \g__cis_p_fp
\fp_do_while:nn { \g__cis_p_fp < 0.5 }
{
\fp_gadd:Nn \g__cis_p_fp { 0.1 }
& \cis_sum:nnn { \g__cis_p_fp } { \g__cis_n_int } { \g__cis_k_int }
}
& \int_eval:n { \g__cis_n_int - \g__cis_k_int }
\bool_lazy_and:nnTF
{ \int_compare_p:n { \g__cis_k_int == \g__cis_n_int } }
{ \int_compare_p:n { \g__cis_k_int == 5 } }
{ \\[1em] } { \\ }
}
\NewDocumentCommand \maketable { }
{
\cis_make_table:
}
\ExplSyntaxOff
\begin{document}
\newcommand\emptycell[1]{\multicolumn{1}{#1}{\cellcolor{white}}}
\sisetup{
round-mode=places,
round-precision=4,
round-integer-to-decimal
}
\begin{tabular}{c|>{\columncolor{pink}}c|ccccc|>{\columncolor{lightgray}}c|}
\cline{2-7}
\rowcolor{pink} \emptycell{c|} &
\multicolumn{6}{c|}{%
$\displaystyle\sum_{v=0}^k \binom{n}{v} p^v q^{n-v} \;,\quad q = 1-p$%
} & \emptycell{c} \\
\rowcolor{pink}
\cellcolor{white} n & \diagbox{$k$}{$p$} & 0.1 & 0.2 & 0.3 & 0.4 & 0.5 & \emptycell{c} \\
\cline{1-8}
\maketable
\cline{2-8}
\rowcolor{lightgray} \emptycell{c} & \emptycell{c|} \emptycell{c|}
& 0.9 & 0.8 & 0.7 & 0.6 & 0.5 & \diagbox{$p$}{$k$} \\
\rowcolor{lightgray} \emptycell{c} & \emptycell{c|} &
\multicolumn{6}{c|}{%
$\displaystyle\sum_{v=k}^n \binom{n}{v} p^v q^{n-v} \;,\quad q = 1-p$%
} \\
\cline{3-8}
\end{tabular}
\end{document}
> ![alt text][1]
[1]: http://texwelt.de/wissen/upfiles/test_38.pnghttp://texwelt.de/wissen/upfiles/test_39.png