﻿ Mathfuns

### Probability and statistics

1. Maximum:max
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{max}\left(x\right)\\ \mathrm{>>>}7\end{array}$

2. Minimum:min
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{min}\left(x\right)\\ \mathrm{>>>}1\end{array}$

3. Sorting:sort
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{sort}\left(x\right)\\ \mathrm{>>>}=\left[1,3,5,7\right]\end{array}$

4. Mean value:mean
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{mean}\left(x\right)\\ \mathrm{>>>}4.0\end{array}$

5. Variance:var
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{var}\left(x\right)\\ \mathrm{>>>}5.0\end{array}$

6. Standard variance:std
• $\begin{array}{l}x=\left[1,3,7,5\right]\\ \mathrm{std}\left(x\right)\\ \mathrm{>>>}2.2360679775\end{array}$

7. Probability of random variable:P{X}
8. Expected value of random variable:E(X)
9. Variance of random variable:D(X)
10. Standard variance of random variable:σ(X)
11. Probability density function of random variable:pdf
12. Die with a sides number parameter:Die(X)
• $\begin{array}{l}x=\mathrm{Die}\left(6\right)\\ \mathrm{>>>}x=\mathrm{Die}\left(6\right)\\ P\left\{\mathrm{x>=4}\right\}\\ \mathrm{>>>}0.5\\ E\left(x\right)\\ \mathrm{>>>}3.5\\ D\left(x\right)\\ \mathrm{>>>}2.91666666666667\\ \sigma \left(x\right)\\ \mathrm{>>>}1.70782512765993\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\left\{1:\frac{1}{6},2:\frac{1}{6},3:\frac{1}{6},4:\frac{1}{6},5:\frac{1}{6},6:\frac{1}{6}\right\}\end{array}$

13. Binomial distribution:b(n,p)

The density of the Binomial distribution is given by:

$\begin{array}{l}P\left\{X=k\right\}=\left(\begin{array}{l}n\\ k\end{array}\right){p}^{k}{\left(\mathrm{1-p}\right)}^{\mathrm{n-k}}\phantom{\rule{20px}{0ex}}k=\mathrm{0,1,2,...,n}\end{array}$

• $\begin{array}{l}x=b\left(4,0.5\right)\\ \mathrm{>>>}x=b\left(4,0.5\right)\\ P\left\{\mathrm{x>=4}\right\}\\ \mathrm{>>>}0.0625\\ E\left(x\right)\\ \mathrm{>>>}2\\ D\left(x\right)\\ \mathrm{>>>}1\\ \sigma \left(x\right)\\ \mathrm{>>>}1\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\left\{0:0.0625,1:0.25,2:0.375,3:0.25,4:0.0625\right\}\end{array}$

14. Poisson distribution:π(λ)

The density of the Poisson distribution is given by:

$\begin{array}{l}P\left\{X=k\right\}=\frac{{\lambda }^{k}{e}^{\mathrm{-\lambda }}}{\mathrm{k!}}\end{array}$

• $\begin{array}{l}x=\pi \left(3\right)\\ \mathrm{>>>}x=\pi \left(3\right)\\ E\left(x\right)\\ \mathrm{>>>}3\\ D\left(x\right)\\ \mathrm{>>>}3\\ \sigma \left(x\right)\\ \mathrm{>>>}1.73205080756888\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\frac{{3}^{k}}{{e}^{3}\mathrm{*\left(k\right)!}}\end{array}$

15. Uniform distribution:U(a,b)

The density of the Uniform distribution is given by:

$\begin{array}{l}f\left(x\right)=\left\{\begin{array}{l}\frac{1}{\mathrm{b-a}}\phantom{\rule{20px}{0ex}}\mathrm{x\in \left[a,b\right]}\\ 0\phantom{\rule{20px}{0ex}}\mathrm{otherwise}\end{array}\right\\end{array}$

• $\begin{array}{l}x=U\left(1,7\right)\\ \mathrm{>>>}x=U\left(1,7\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}0.666666666666667\\ E\left(x\right)\\ \mathrm{>>>}4\\ D\left(x\right)\\ \mathrm{>>>}3\\ \sigma \left(x\right)\\ \mathrm{>>>}1.73205080756888\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\frac{1}{6}\end{array}$

16. Exponential distribution:Expd(θ)

The density of the Exponential distribution is given by:

$\begin{array}{l}f\left(x\right)=\left\{\begin{array}{l}\frac{1}{\theta }{e}^{\mathrm{-x/\theta }}\phantom{\rule{20px}{0ex}}\mathrm{x>0}\\ 0\phantom{\rule{20px}{0ex}}\mathrm{otherwise}\end{array}\right\\end{array}$

• $\begin{array}{l}x=\mathrm{Expd}\left(10\right)\\ \mathrm{>>>}x=\mathrm{Expd}\left(10\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}9.35762296884017e-14\\ E\left(x\right)\\ \mathrm{>>>}0.1\\ D\left(x\right)\\ \mathrm{>>>}0.01\\ \sigma \left(x\right)\\ \mathrm{>>>}0.1\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}10*{e}^{\mathrm{-10}*x}\end{array}$

17. Normal distribution:N(μ,σ)

The density of the Normal distribution is given by:

$\begin{array}{l}f\left(x\right)=\frac{1}{\sigma \sqrt{2\pi }}{e}^{-\frac{{\left(\mathrm{x-\mu }\right)}^{2}}{2{\sigma }^{2}}}\end{array}$

• $\begin{array}{l}x=N\left(0,1\right)\\ \mathrm{>>>}x=N\left(0,1\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}0.00134989803163009\\ E\left(x\right)\\ \mathrm{>>>}0\\ D\left(x\right)\\ \mathrm{>>>}1\\ \sigma \left(x\right)\\ \mathrm{>>>}1\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\frac{\sqrt{2}}{2*\sqrt{\pi }}*{e}^{-\frac{{x}^{2}}{2}}\end{array}$

18. Chi-squared distribution:${\chi }^{2}$

The density of the Chi-squared distribution is given by:

$\begin{array}{l}f\left(x\right)=\left\{\begin{array}{l}\frac{1}{{2}^{\mathrm{n/2}}\Gamma \left(\mathrm{n/2}\right)}{x}^{\mathrm{n/2-1}}{e}^{\mathrm{-x/2}}\phantom{\rule{20px}{0ex}}\mathrm{x>0}\\ 0\phantom{\rule{20px}{0ex}}\mathrm{otherwise}\end{array}\right\\end{array}$

• $\begin{array}{l}x={\chi }^{2}\left(6\right)\\ \mathrm{>>>}x={\chi }^{2}\left(6\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}0.808846830538058\\ E\left(x\right)\\ \mathrm{>>>}6\\ D\left(x\right)\\ \mathrm{>>>}12\\ \sigma \left(x\right)\\ \mathrm{>>>}3.46410161513775\\ \mathrm{pdf}\left(x\right)\\ \mathrm{>>>}\frac{{x}^{2}}{16}*{e}^{-\frac{x}{2}}\end{array}$

19. t distribution:t(n)

The density of the t distribution is given by:

$\begin{array}{l}f\left(x\right)=\frac{\Gamma \left(\mathrm{\left(n+1\right)/2}\right)}{\sqrt{\mathrm{\pi n}}\Gamma \left(\mathrm{n/2}\right)}{\left(\mathrm{1+}\frac{{x}^{2}}{n}\right)}^{\mathrm{-\left(n+1\right)/2}}\end{array}$

• $\begin{array}{l}x=t\left(6\right)\\ \mathrm{>>>}x=t\left(6\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}0.0120040983778655\\ E\left(x\right)\\ \mathrm{>>>}0\\ D\left(x\right)\\ \mathrm{>>>}1.5\\ \sigma \left(x\right)\\ \mathrm{>>>}1.22474487139159\end{array}$

20. F distribution:F(m,n)

The density of the F distribution is given by:

$\begin{array}{l}f\left(x\right)=\left\{\begin{array}{l}\frac{\Gamma \left(\mathrm{\left(m+n\right)/2}\right){\mathrm{\left(m/n\right)}}^{\mathrm{m/2}}{x}^{\mathrm{\left(m/2\right)-1}}}{\Gamma \left(\mathrm{m/2}\right)\Gamma \left(\mathrm{n/2}\right){\mathrm{\left(1+\left(mx/n\right)\right)}}^{\mathrm{\left(m+n\right)/2}}}\phantom{\rule{20px}{0ex}}\mathrm{x>0}\\ 0\phantom{\rule{20px}{0ex}}\mathrm{otherwise}\end{array}\right\\end{array}$

• $\begin{array}{l}x=F\left(2,6\right)\\ \mathrm{>>>}x=F\left(2,6\right)\\ P\left\{\mathrm{x>3}\right\}\\ \mathrm{>>>}0.125\\ E\left(x\right)\\ \mathrm{>>>}1.5\\ D\left(x\right)\\ \mathrm{>>>}6.75\\ \sigma \left(x\right)\\ \mathrm{>>>}2.59807621135332\end{array}$