File:Binomial confidence band.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file(SVG file, nominally 720 × 540 pixels, file size: 43 KB)

Summary

Description
English: Illustration of confidence bands using simulated data.
Date
Source Own work
Author Skbkekas
Other versions

[edit]

SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
 
The file size of this SVG plot may be irrationally large because its text has been converted to paths inhibiting translations.
Source code
InfoField

Python code

import 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:
w:en:Creative Commons
attribution
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/TimeThumbnailDimensionsUserComment
current04:11, 11 April 2009Thumbnail for version as of 04:11, 11 April 2009720 × 540 (43 KB)SkbkekasAdded the line for true proportions.
04:02, 11 April 2009Thumbnail for version as of 04:02, 11 April 2009720 × 540 (41 KB)Skbkekas{{Information |Description={{en|1=Illustration of confidence bands using simulated data.}} |Source=Own work by uploader |Author=Skbkekas |Date=April 11, 2009 |Permission= |other_versions= }} <!--{{ImageUpload|full}}-->
The following pages on the English Wikipedia use this file (pages on other projects are not listed):

Global file usage

The following other wikis use this file: