Q: Python array values differ from defined function I have defined and function and calling it to store the computed values in an array. However the  values in array are different than what they should be. I have plotted both the output of the function and stored array values. Can anyone help me resolve this issue. Here is the code and the output. 
from numpy import linspace, exp
import matplotlib.pyplot as pl

def gaussian(x, off, amp, cen, wid):
   return off+amp * exp(-(x-cen)**2 /wid**2)

PhaseArray = [0 for x in range (100)]

for x in range(100):
  PhaseArray[x] = gaussian(x, 0, 1000, 50, 15)

x = linspace(0,99,100)
fig = pl.figure()
pl.plot(PhaseArray, 'go-')
pl.plot(x, gaussian(x, 0, 1000, 50, 15), 'ro-')
pl.show()

The output plot looks like


A: linspace provides a vector of float numbers that go to gaussian as a vector and are processed according to numpy operators over vectors. On the other hand, to fill PhaseArray you feed gaussian by integer x that is processed in a different way. It explains the difference.
