Doc: Add Statistical examples

This commit is contained in:
Bertrand Benjamin 2019-07-12 09:57:18 +02:00
parent 6dc4743d8e
commit b5bb4fef24

View File

@ -1,6 +1,6 @@
# Mapytex
Formal calculus with explanation python module.
Formal calculus with explanation python module and exercises creation tools.
[French wiki](https://opytex.org/pymath)
@ -56,3 +56,38 @@ pip install -U mapytex
\frac{ 6 + 10 }{ 15 }
\frac{ 16 }{ 15 }
```
### Statistical tools
``` python
>>> from mapytex import Dataset
>>> d = Dataset.random(10, "Poids des sacs (kg)", "gauss", (4, 1), v_min=1)
>>> print(d)
[3.03, 5.94, 4.46, 2.58, 5.32, 3.22, 5.75, 4.22, 1.81, 4.71]
>>> d.mean()
4.1
>>> d.effectif_total()
10
>>> d.sum()
41.04
>>> print(d.tabular_latex(2))
\begin{tabular}{|c|*{5}{c|}}
\hline
3.03 & 5.94 & 4.46 & 2.58 & 5.32 \\
\hline
3.22 & 5.75 & 4.22 & 1.81 & 4.71 \\
\hline
\end{tabular}
>>> w = WeightedDataset([1, 2, 3, 4], "Enfants", [10, 11, 12, 13])
>>> print(w)
{1: 10, 2: 11, 3: 12, 4: 13}
>>> print(w.tabular_latex())
\begin{tabular}{|c|*{4}{c|}}
\hline
Enfants & 1 & 2 & 3 & 4 \\
\hline
Effectifs & 10 & 11 & 12 & 13 \\
\hline
\end{tabular}
```