Scipy Flashcards

1
Q

1)generate F_H0 binomial distribution with p = 0.5, n = 16

n - number of bernulli distributed random variables

A

F_H0 = stats.binom(n, p)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

2)plot histogramm of F_H0

A

x = np.linspace(0,n,n+1)

pylab.bar(x, F_H0.pmf(x), align = ‘center’)
xlim(-0.5, n+0.5)
pylab.show()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

3)Color with red right tail of histogram

A

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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

a) stats.binom_test(12, 16, 0.5, alternative = ‘greater’)

b) stats.binom_test(12, 16, 0.5, alternative = ‘two-sided’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

calculate observed frequences in data

A

observed_frequences = np.bincount(data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Calculate chi squared statistic on observed_frequences and expected_frequences, when mean in expected_frequences was estimated using data => ddof=1

A

stats.chisquare(observed_frequences, expected_frequences, ddof = 1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
#1
calculate observed frequences(count) in data on 2D grid with 5*5=25 bins
#2
reshape matrix in (25,1) vector
A
#1
actual_freq = 
scipy.stats.binned_statistic_2d(x, y, None, statistic='count', bins=5).statistic
#2
actual_freq_reshaped = actual_freq.reshape((25,))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly