Scipy Flashcards
1)generate F_H0 binomial distribution with p = 0.5, n = 16
n - number of bernulli distributed random variables
F_H0 = stats.binom(n, p)
2)plot histogramm of F_H0
x = np.linspace(0,n,n+1)
pylab.bar(x, F_H0.pmf(x), align = ‘center’)
xlim(-0.5, n+0.5)
pylab.show()
3)Color with red right tail of histogram
pylab.bar(x, F_H0.pmf(x), align = ‘center’)
pylab.bar(np.linspace(12,16,5), F_H0.pmf(np.linspace(12,16,5)), align = ‘center’, color=’red’)
xlim(-0.5, 16.5)
pylab.show()
4) Calculate p-value(достигаемый уровень значимости)
a) one-tailed and
b) two-tailed
for binomial disributed random variable(n=16, p=0.5,n+=12)
Probability to get statistic T>=t(statistical criterion) under the condition of true H0:
p=P(T>=t|H0)
a) stats.binom_test(12, 16, 0.5, alternative = ‘greater’)
b) stats.binom_test(12, 16, 0.5, alternative = ‘two-sided’)
calculate observed frequences in data
observed_frequences = np.bincount(data)
Calculate chi squared statistic on observed_frequences and expected_frequences, when mean in expected_frequences was estimated using data => ddof=1
stats.chisquare(observed_frequences, expected_frequences, ddof = 1)
#1 calculate observed frequences(count) in data on 2D grid with 5*5=25 bins #2 reshape matrix in (25,1) vector
#1 actual_freq = scipy.stats.binned_statistic_2d(x, y, None, statistic='count', bins=5).statistic #2 actual_freq_reshaped = actual_freq.reshape((25,))