# Ten Sigma Event
Statistical Consequences of Fat Tails (Page 53)


```python
import pandas as pd
from sympy.stats import P, E, variance, std, Die, Normal
from sympy import Eq, simplify
```

### Normal Distribution

Taleb says the probability of 10 sigma in a normal distribution is 1 in 1.31x10^-23. 
Let's see if we can make that value appear.


```python
Z = Normal('Z', 0, 1) # Declare a Normal random variable with mean 0, std 1
```

##### Check I've the right Distribution


```python
E(Z)
```




$\displaystyle 0$




```python
P(Z>0) # Probability X is greater than 3
```




$\displaystyle \frac{1}{2}$




```python
# Check The Standard Deviation
std(Z).evalf()
```




$\displaystyle 1.0$



#### Calculate 10 Sigma Probability


```python
proba = P(Z>10).evalf()
```


```python
1/proba # Number of samples until expectation is one occurrence... i.e. a 1 in 1.312*10**23 chance
```




$\displaystyle 1.3123612710498 \cdot 10^{23}$



# Power Law (Student-T Distribution)


```python
from sympy.stats import StudentT
```


```python
T = StudentT('T', 2)
```


```python
E(T)
```




$\displaystyle 0$



Variance of student t with parameter 2 is undefined


```python
#variance(T) # Variance is infinite
#std(T) # hmm I wonder why this is
```

If we've done this right the survival function at a value of 10 should be 1 in 203:


```python
1/203
```




    0.0049261083743842365




```python
P(T>10).evalf()
```




$\displaystyle 0.00492622851166285$



# Replicate the P(Gaussian) Table...


```python
gaussian_values = [0.5, 0.999, 0.9999, 0.99999, 0.999999, 1] # P(Gaussian) values to check for
```

We want to find P(Gaussian|Event):

\begin{equation*}
\frac{P(Gaussian)*P(Event|Gaussian)}{\Bigl(1-P(Gaussian)\Bigr)*P(Event|NonGaussian)+P(Gaussian)*P(Event|Gaussian)}
\end{equation*}


```python
p_if_gauss = P(Z>10).evalf()
p_if_nongauss = P(T>10).evalf()
```


```python
1/p_if_gauss
```




$\displaystyle 1.3123612710498 \cdot 10^{23}$




```python
1/p_if_nongauss
```




$\displaystyle 202.995049383621$




```python
p_gauss_if_event_list = []
for p_gauss in gaussian_values:
    
    numerator = p_gauss * p_if_gauss
    denominator = (1-p_gauss)*p_if_nongauss+p_gauss*p_if_gauss
    
    p_gauss_if_event = numerator/denominator
    
    p_gauss_if_event_list.append(p_gauss_if_event)
```


```python
d = {'P(Gaussian)':gaussian_values, 'P(Gaussian|Event)':p_gauss_if_event_list}
page_53_table = pd.DataFrame(d)
```


```python
page_53_table
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>P(Gaussian)</th>
      <th>P(Gaussian|Event)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>0.500000</td>
      <td>1.54679244093540e-21</td>
    </tr>
    <tr>
      <th>1</th>
      <td>0.999000</td>
      <td>1.54524564849446e-18</td>
    </tr>
    <tr>
      <th>2</th>
      <td>0.999900</td>
      <td>1.54663776169147e-17</td>
    </tr>
    <tr>
      <th>3</th>
      <td>0.999990</td>
      <td>1.54677697301803e-16</td>
    </tr>
    <tr>
      <th>4</th>
      <td>0.999999</td>
      <td>1.54679089409848e-15</td>
    </tr>
    <tr>
      <th>5</th>
      <td>1.000000</td>
      <td>1.00000000000000</td>
    </tr>
  </tbody>
</table>
</div>



d5bf6aae3067741b0a755f95bc6283646d075237
ipynb
Jupyter Notebook
notebooks/Notebook-04 - Sympy 10 Sigma Event.ipynb
FergM/fattails
453481b07701fbcb375bde2a0639633cc66d156e
MIT
2020-12-23T16:34:16.000Z
2022-03-02T06:18:13.000Z
notebooks/Notebook-04 - Sympy 10 Sigma Event.ipynb
drettt/fattails
d7988f7d5329504105393782e1ccf979fe2f3a89
MIT
2020-10-26T11:23:16.000Z
2021-08-08T20:33:14.000Z
notebooks/Notebook-04 - Sympy 10 Sigma Event.ipynb
drettt/fattails
d7988f7d5329504105393782e1ccf979fe2f3a89
MIT
2021-02-11T09:44:08.000Z
2022-02-26T00:00:47.000Z
Qwen/Qwen-72B
1. YES
2. YES