Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Last active July 17, 2020 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaraM92/ded4fe90d1e6f6ba6d5767f4ede0bd8d to your computer and use it in GitHub Desktop.
Save SaraM92/ded4fe90d1e6f6ba6d5767f4ede0bd8d to your computer and use it in GitHub Desktop.
#Import Essential Libraries
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stat
#Generate the Binomial Distribution
x = np.arange(0, 25)
noOfTrials = 20 #Number of trials
prob = 0.9 #probability of success
binom = stat.binom.pmf(x, noOfTrials, prob)
plt.plot(x, binom, color="#8d0801")
plt.xlabel('Random Variable', fontsize=15)
plt.ylabel('Probability', fontsize=15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment