File:Binomial confidence band.svg
From formulasearchengine
Jump to navigation
Jump to search
Original file (SVG file, nominally 720 × 540 pixels, file size: 43 KB)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionBinomial confidence band.svg |
English: Illustration of confidence bands using simulated data. |
| Date | |
| Source |
Own work |
| Author | Skbkekas |
| Other versions |
[edit]
|
| SVG development InfoField | |
| Source code InfoField | 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)
## Multiplier for 95% simultaneous confidence band using Bonferroni method.
f = -sp.ndtri(0.025/len(P))
plt.clf()
a = plt.plot(X, Y, '-', color='black')
plt.hold(True)
b = plt.plot(X, Y+2*S, '-', color='royalblue')
plt.plot(X, Y-2*S, '-', color='royalblue')
c = plt.plot(X, Y+f*S, '-', color='orangered')
plt.plot(X, Y-f*S, '-', color='orangered')
d = plt.plot(X, P, '-', color='green')
plt.ylim(0,1)
plt.xlim(18,80)
B = plt.legend((a,b,c,d), ('Estimate', '95% point-wise CB',\
'95% simultaneous CB', "True proportions"),\
'upper left')
B.draw_frame(False)
plt.xlabel("Age")
plt.ylabel("Proportion supporting candidate A")
plt.savefig("binomial_confidence_band.png")
plt.savefig("binomial_confidence_band.svg")
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution 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.
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
11 April 2009
image/svg+xml
33d0528562d7f5ba7ad3db88642916cfb5004793
44,235 byte
540 pixel
720 pixel
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 06:11, 11 April 2009 | 720 × 540 (43 KB) | wikimediacommons>Skbkekas | Added the line for true proportions. |
File usage
There are no pages that use this file.