Plotting py for Rayleigh

This commit is contained in:
i.ortega 2020-05-21 22:28:05 +02:00
parent 86c5cceceb
commit 6ddbede5a4
1 changed files with 31 additions and 0 deletions

31
src/plot.py Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
import math
def rayleighDistribution(sigma2):
return lambda x: x / sigma2 * math.exp(-math.pow(x, 2) / (2 * sigma2))
ray = lambda x: rayleighDistribution(20)(x * 5.8 + 0.2) / 0.1356243
# 100 linearly spaced numbers
x = np.linspace(0, 1, 100)
y = list(map(ray, x))
# setting the axes at the centre
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines["left"].set_position("zero")
ax.spines["bottom"].set_position("zero")
ax.spines["right"].set_color("none")
ax.spines["top"].set_color("none")
ax.xaxis.set_ticks_position("bottom")
ax.yaxis.set_ticks_position("left")
# plot the function
plt.plot(x, y, "r")
# show the plot
plt.show()