0

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>,

1 Answer 1

1

In your code, a is 2-d array with 1 item.

a=a.flatten()
plt.plot(a)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.