Created
February 17, 2019 05:54
-
-
Save ipreencekmr/bee1bcc5b93c983976333983a095bd15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.stats as stats | |
total_numbers = [] | |
for i in range(0,30): | |
total_numbers.append(np.random.randint(0,100)) | |
print('total_numbers are:\n ', total_numbers,'\n') | |
#lets take success probability from population (num >= 60 is success) | |
num_greater_than_59 = list(filter(lambda x:x > 60, total_numbers)) | |
prob_getting_success = len(num_greater_than_59) / len(total_numbers) | |
print('Numbers greater than 59 are: %i \n '% len(num_greater_than_59)); | |
print('Probability of success from previous data = %.2f \n\n'%prob_getting_success) | |
#Choose 7 random values from total list | |
seven_random_values = [] | |
for n in range(0,7): | |
seven_random_values.append(total_numbers[np.random.randint(0,6)]) | |
seven_random_values | |
#lets create binomial distribution | |
n = 7 | |
k = np.arange(0, n+1) | |
p = prob_getting_success | |
binom = stats.binom.pmf(k, n, p) | |
mean = n * p | |
#Q > What is mean of binomial | |
print('Mean by binomial : ',mean) | |
print('Mean of 7 random values ',np.array(seven_random_values).mean()) | |
print('Mean of population ',np.array(total_numbers).mean()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment