Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy.random import randn
- from scipy.stats.mstats import mode
- from scipy.stats import skew, kurtosis, mannwhitneyu
- from matplotlib.pyplot import hist, show, clf, title
- import numpy as np
- def z_test(mean, expected, std, n):
- z = ((mean - expected) / std) * np.sqrt(n)
- return z
- x1 = np.zeros(31)
- x2 = np.zeros(31)
- a = 183
- c = 10
- m = 102
- x1[0] = abs(randn()) / m
- x2[0] = abs(randn()) / m
- for i in range(1, 31):
- x1[i] = ((a * x1[i-1] + c) % m) / m
- x2[i] = ((a * x2[i - 1] + c) % m) / m
- sample1 = x1[1:]
- sample2 = x2[1:]
- print(sample1, '\n', sample2)
- mean1 = np.mean(sample1)
- mode1 = mode(sample1)
- med1 = np.median(sample1)
- var1 = np.var(sample1)
- std1 = np.sqrt(var1)
- skew1 = skew(sample1)
- kurt1 = kurtosis(sample1)
- z1 = z_test(mean1, 0.5, std1, len(sample1))
- print('Średnia: {}\nModa: {}\nMediana: {}\nWariancja: {}\nOdch.stand.: {}\nSkośność: {}\nKurtoza: {}\nZ-Test: {}\n'
- .format(mean1, mode1, med1, var1, std1, skew1, kurt1, z1))
- title('Ciag 1')
- hist(sample1, bins=5)
- show()
- clf()
- mean2 = np.mean(sample2)
- mode2 = mode(sample2)
- med2 = np.median(sample2)
- var2 = np.var(sample2)
- std2 = np.sqrt(var2)
- skew2 = skew(sample2)
- kurt2 = kurtosis(sample2)
- z2 = z_test(mean2, 0.5, std2, len(sample2))
- print('Średnia: {}\nModa: {}\nMediana: {}\nWariancja: {}\nOdch.stand.: {}\nSkośność: {}\nKurtoza: {}\nZ-Test: {}\n'
- .format(mean2, mode2, med2, var2, std2, skew2, kurt2, z2))
- title('Ciag 2')
- hist(sample2, bins=5)
- show()
- print("Test Manna-Whitneya", mannwhitneyu(sample1, sample2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement