samedi 23 juin 2018

plot shuffled array numpy

I am writting a very simple script, one that plot a sin using jupyter notebook (python 3). when I put:

import numpy
import matplotlib.pyplot as plt
x=np.arange(0.0,5*np.pi,0.001)
y = np.sin(x)
plt.plot(x,y)

The plot is fine.

However if :

import numpy
import matplotlib.pyplot as plt
x=np.arange(0.0,5*np.pi,0.001)
np.random.shuffle(x)
y = np.sin(x)
plt.plot(x,y)

the image is enter image description here

I don't understand why shuffling the x BEFORE I ran sin does it.
thank you




Aucun commentaire:

Enregistrer un commentaire