End sem 7; week 2 winter session 2025

This commit is contained in:
Aidan Sharpe
2025-01-15 17:59:04 -05:00
parent a00dde9ad4
commit a8d165aa1a
123 changed files with 19367 additions and 70 deletions

View File

@ -0,0 +1,30 @@
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
def laplacian_distribution(n_0, std_dev):
return np.exp(-np.sqrt(2)*np.abs(n_0)/std_dev) / (np.sqrt(2)*std_dev)
def main():
r_0 = np.linspace(-5,5,1000)
A = 1
std_dev = 1
low_dist = laplacian_distribution(r_0 - A, std_dev)
up_dist = laplacian_distribution(r_0 + A, std_dev)
plt.plot(r_0, low_dist, label="$s_1$")
plt.plot(r_0, up_dist, label="$s_2$")
P_error = (up_dist + low_dist - np.abs(up_dist-low_dist))/2
plt.fill_between(r_0, P_error, color=(0,0,0,0), hatch="//", edgecolor='k', label="$P_e$")
plt.legend()
plt.savefig("Probability of error")
plt.show()
if __name__ == "__main__":
main()