summaryrefslogtreecommitdiff
path: root/expt_normal_distribution.py
diff options
context:
space:
mode:
Diffstat (limited to 'expt_normal_distribution.py')
-rwxr-xr-xexpt_normal_distribution.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/expt_normal_distribution.py b/expt_normal_distribution.py
new file mode 100755
index 0000000..272b9b6
--- /dev/null
+++ b/expt_normal_distribution.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+import numpy as np
+import matplotlib.pyplot as plt
+from matplotlib.ticker import PercentFormatter
+
+
+def function_pdf(element: list[int]):
+ plt.hist(element, bins=500, histtype='step')
+ plt.show()
+
+
+def function_cdf(element: list[int]):
+ plt.hist(element, bins=500, cumulative=True, histtype='step')
+ plt.show()
+
+
+def function_1000_cdf(element: list[int]):
+ plt.hist(element, bins=250, histtype='step', label='x', cumulative=True,
+ weights=np.ones(len(element)) / len(element))
+ plt.hist(element[:1000], bins=100, histtype='step', label='y', cumulative=True, weights=np.ones(1000) / 1000)
+ plt.gca().yaxis.set_major_formatter(PercentFormatter(1))
+ plt.show()
+
+
+def normal_distribution() -> list[int]:
+ with open('normal_distribution.txt') as fin:
+ context = fin.read()
+ return list(map(int, context.splitlines()))
+
+
+if __name__ == '__main__':
+ elements = normal_distribution()
+ function_pdf(elements)
+ function_cdf(elements)
+ function_1000_cdf(elements)