File:Binomial confidence band uk.svg
Summary
| Description |
English: Illustration of confidence bands using simulated data, labelled in Ukrainian
Українська: Ілюстрація довірчих смуг із застосуванням імітованих даних |
| Date | |
| Source | |
| Author |
|
| Other versions |
[]
|
| SVG development | Category:Valid SVG created with Matplotlib code#Binomial%20confidence%20band%20uk.svg |
| Source code | Python codeimport numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
X = np.arange(18, 81, 2)
P = 1/(1+np.exp(1-0.2*np.sqrt(X-18)))
Y,S,n = [],[],500
for i,x in enumerate(X):
y = 1*(np.random.uniform(size=n)<P[i])
p = y.mean()
Y.append(p)
S.append(np.sqrt(p*(1-p)/n))
Y = np.array(Y)
S = np.array(S)
## Множник для одночасно 95 %-вої довірчої смуги із застосуванням методу Бонферроні.
f = -sp.ndtri(0.025/len(P))
plt.clf()
plt.plot(X, Y, '-', color='black', label = 'Оцінка')
plt.plot(X, Y+2*S, '-', color='royalblue', label = 'Поточково 95 %-ва ДС')
plt.plot(X, Y-2*S, '-', color='royalblue')
plt.plot(X, Y+f*S, '-', color='orangered', label = 'Одночасно 95 %-ва ДС')
plt.plot(X, Y-f*S, '-', color='orangered')
plt.plot(X, P, '-', color='green', label = "Істинні частки")
plt.ylim(0,1)
plt.xlim(18,80)
plt.legend(frameon=False)
plt.xlabel("Вік")
plt.ylabel("Частка тих, хто підтримує кандидата А")
plt.savefig("binomial_confidence_band_uk.png")
plt.savefig("binomial_confidence_band_uk.svg")
|
Licensing
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.