Confused with the python results after using some function -




i have problem here. please @ code , don't know what's wrong in code. simple results confusing me. attached code below.

import numpy np import matplotlib.pyplot plt  def s(xc):     n=len(xc)     r=0.0     s=0.0      # calculation quartile     m in range(0,n-1):         n in range(m+1,n):             if (xc[m] > xc[n]):                 q=xc[m]                 xc[m]=xc[n]                 xc[n]=q      if (n % 4 < 2):         q=(xc[n-n/4-1] + xc[n-n/4])*0.5-(xc[n/4-1]+xc[n/4])*0.5     else:         q=xc[n-n/4-1]-xc[n/4]      #calculation standard deviation      m in range(0,n):         r+=xc[m]         s+=xc[m]*xc[m]     r=np.sqrt(s/n-(r/n)*(r/n))      #calculation     if (q<r):         s=q     else:         s=r     hasil=0.9*(s/1.34)*pow(n,-0.2)     return hasil  fc=0.3 fm=0.02 mu=1 nsim=10   bb=[] nn in range(0,nsim):     bb.append((1+(mu*np.cos(2*np.pi*fm*nn)))*np.cos(2*np.pi*fc*nn))  print bb print s(bb) print bb 

the code works while delete function of "s" in main function, however, after "s" function, data on variable "bb" different though print same variable. don't understand happened.

i appreciate help. lot

alvin

calling s(bb) changes contents of bb through statements xc[m]=xc[n].





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -