Computer assignment

profileturtletime98
2x.docx

from parselib import *

# Counts the number of successes in n independent trials when the probability of success each time is pr.

# [X] is binomially-distributed with n trials, pr probability

n = 30

pr = 0.32

rv = stats.binom(n, pr)

# Specify the x-values of interest

t = range(0, n+1)

# New figure

figure()

grid(True)

# Draw the PMF at the specified x-values

X_pmf = rv.pmf(t)

title('PMF of a Binomial distribution')

xlabel('Value, X')

ylabel('Probability, P(X)')

stem(t, X_pmf)