Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. from numpy.random import randn
  2. from scipy.stats.mstats import mode
  3. from scipy.stats import skew, kurtosis, mannwhitneyu
  4. from matplotlib.pyplot import hist, show, clf, title
  5. import numpy as np
  6.  
  7.  
  8. def z_test(mean, expected, std, n):
  9. z = ((mean - expected) / std) * np.sqrt(n)
  10. return z
  11.  
  12.  
  13. x1 = np.zeros(31)
  14. x2 = np.zeros(31)
  15. a = 183
  16. c = 10
  17. m = 102
  18. x1[0] = abs(randn()) / m
  19. x2[0] = abs(randn()) / m
  20.  
  21. for i in range(1, 31):
  22. x1[i] = ((a * x1[i-1] + c) % m) / m
  23. x2[i] = ((a * x2[i - 1] + c) % m) / m
  24.  
  25. sample1 = x1[1:]
  26. sample2 = x2[1:]
  27. print(sample1, '\n', sample2)
  28.  
  29. mean1 = np.mean(sample1)
  30. mode1 = mode(sample1)
  31. med1 = np.median(sample1)
  32. var1 = np.var(sample1)
  33. std1 = np.sqrt(var1)
  34. skew1 = skew(sample1)
  35. kurt1 = kurtosis(sample1)
  36. z1 = z_test(mean1, 0.5, std1, len(sample1))
  37. print('Średnia: {}\nModa: {}\nMediana: {}\nWariancja: {}\nOdch.stand.: {}\nSkośność: {}\nKurtoza: {}\nZ-Test: {}\n'
  38. .format(mean1, mode1, med1, var1, std1, skew1, kurt1, z1))
  39. title('Ciag 1')
  40. hist(sample1, bins=5)
  41. show()
  42. clf()
  43.  
  44. mean2 = np.mean(sample2)
  45. mode2 = mode(sample2)
  46. med2 = np.median(sample2)
  47. var2 = np.var(sample2)
  48. std2 = np.sqrt(var2)
  49. skew2 = skew(sample2)
  50. kurt2 = kurtosis(sample2)
  51. z2 = z_test(mean2, 0.5, std2, len(sample2))
  52. print('Średnia: {}\nModa: {}\nMediana: {}\nWariancja: {}\nOdch.stand.: {}\nSkośność: {}\nKurtoza: {}\nZ-Test: {}\n'
  53. .format(mean2, mode2, med2, var2, std2, skew2, kurt2, z2))
  54. title('Ciag 2')
  55. hist(sample2, bins=5)
  56. show()
  57. print("Test Manna-Whitneya", mannwhitneyu(sample1, sample2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement