I am writing some code but have problems plotting the final values in a, please see code below:
import scipy.stats
import matplotlib.pyplot as plt
import numpy as np
a = np.zeros((1, 1000))
for i in range(1000):
samples = scipy.stats.norm.rvs(mu, sigma, i 1)
fcn = (abs(samples))**3
a[0, i] = (sum(fcn > 13) / len(fcn))
plt.plot(a) # Would like to plot the values in a, row-wise, against their index values. How to do that?
I am quite sure this is easy, but just typing plt.plot(a) yields an empty plot with messages of the form :
<matplotlib.lines.Line2D at 0x1fb259b44c0>,
<matplotlib.lines.Line2D at 0x1fb259b4580>,
<matplotlib.lines.Line2D at 0x1fb259b4640>,
<matplotlib.lines.Line2D at 0x1fb259b4700>,
<matplotlib.lines.Line2D at 0x1fb259b47c0>,
<matplotlib.lines.Line2D at 0x1fb259b4880>,
<matplotlib.lines.Line2D at 0x1fb259b4940>,
CodePudding user response:
In your code, a
is 2-d array with 1 item.
a=a.flatten()
plt.plot(a)