# Lognormal distribution EF (Error Factor)
$$EF=\sqrt{\frac{p95}{p05}}=\frac{p95}{p50}=\frac{p50}{p5}$$


```python
# Загрузка нужных библиотек
import numpy as np
from scipy.stats import lognorm
from sympy import symbols, solve, exp, log
import matplotlib.pyplot as plt
```


```python
ef, mean, sigma, median, ci90 = symbols('ef mean sigma median ci90', Positive=True)
sigma = log(ef)/ci90
```


```python
solve(exp(log(median)+(sigma**2)/2)-mean,median)
```


```python
solve(solve(log(ef)/ci90-sigma,,sigma)
```


```python
# Настройка стиля рисунков
# Включение модного, черного стиля для рисунков
#plt.style.use('dark_background')
# Изменение стандартного шрифта на Linux-своместимый
#plt.rcParams["font.family"] = 'Liberation Mono'
# Изменяем стандартный размер шрифта
plt.rcParams.update({'font.size': 12})
# Изменяем стандартный размер картинки
plt.rcParams['figure.figsize'] = [16, 8]
```


```python
m = 3e-5
x = np.linspace(0,1)
qq = np.linspace(0.01,0.99)
x2 = np.linspace(0, 3*m)
fig, axs = plt.subplots(nrows=1, ncols=2)
for ef in range(2,6):
    ci90 = 1.64485
    sigma = np.log(ef)/ci90
    med = m*np.exp(-(sigma**2)/2)
    axs[0].plot(x, lognorm.ppf(qq, s=sigma, scale= med), '--')
    axs[0].ticklabel_format(axis="both", style="sci", scilimits=(0,0))
    axs[1].plot(x2, lognorm.pdf(x2, s=sigma, scale= med), '--')
    mean = lognorm.mean(s=sigma, scale= med)
    median = lognorm.median(s=sigma, scale= med)
    axs[1].plot(mean, lognorm.pdf(mean,s=sigma, scale= med), 'o', c='grey')
    axs[1].plot(median, lognorm.pdf(median,s=sigma, scale= med), '^', c='grey')
    print(mean)
    axs[1].ticklabel_format(axis="both", style="sci", scilimits=(0,0))
axs[0].axhline(m, ls=':', color='grey')
axs[0].text(0, m*1.01, f'mean={m}')
axs[1].axvline(m, ls= ':', color='grey')
axs[1].text(m*1.01, 0, f'mean={m}')
axs[0].legend(range(2,6))
axs[0].grid(linestyle=':')
axs[1].grid(linestyle=':')
plt.show()
```

9fee0c90c533b03945fee7660af533d125c663bd
ipynb
Jupyter Notebook
Lognormal_EF.ipynb
HexQuant/exx
73d8b67883ff52ed0eac45c03bd17ffb3fc13263
MIT
Lognormal_EF.ipynb
HexQuant/exx
73d8b67883ff52ed0eac45c03bd17ffb3fc13263
MIT
Lognormal_EF.ipynb
HexQuant/exx
73d8b67883ff52ed0eac45c03bd17ffb3fc13263
MIT
Qwen/Qwen-72B
1. YES
2. YES