diff --git a/src/experiments/algorithms/distribution.py b/src/experiments/algorithms/distribution.py new file mode 100644 index 0000000..f890e4a --- /dev/null +++ b/src/experiments/algorithms/distribution.py @@ -0,0 +1,37 @@ +import numpy as np +import matplotlib.pyplot as plt +import math + +mean = 125 +sd = 20 +N = 255 +f = np.zeros(N, dtype=np.longdouble) + +def calcNormalFunc(mean, sd, len): + f = np.zeros(len, dtype=np.longdouble) + + # calculate PDF + for x in range(len): + exp = (-(x - mean) ** 2)/(2 * sd ** 2) + f[x] = 1 / math.sqrt(2 * np.pi * sd** 20 ) * (math.exp(exp)) + + # normalize PDF + max = np.amax(f) + min = np.amin(f) + for x in range(len): + f[x] = (f[x] - min) / (max - min) + + return f + +f = calcNormalFunc(mean, sd, N) + +plt.title("PDF: $\mu = %d$, $\sigma = %d$"%(mean, sd)) +plt.plot(f) +plt.grid() +plt.xlim(0, 255) +plt.ylim(0, 1.05) +plt.show() + +print("Score at 1 sigma: %f"%f[sd+mean]) +print("Score at 2 sigma: %f"%f[2*sd+mean]) +print("Score at 3 sigma: %f"%f[3*sd+mean]) \ No newline at end of file