# [Scipy-svn] r2180 - in trunk/Lib: misc signal special stats

scipy-svn at scipy.org scipy-svn at scipy.org
Sun Aug 27 02:44:22 CDT 2006

```Author: oliphant
Date: 2006-08-27 02:44:15 -0500 (Sun, 27 Aug 2006)
New Revision: 2180

Modified:
trunk/Lib/misc/common.py
trunk/Lib/signal/waveforms.py
trunk/Lib/special/basic.py
trunk/Lib/stats/distributions.py
trunk/Lib/stats/stats.py
Log:

Modified: trunk/Lib/misc/common.py
===================================================================
--- trunk/Lib/misc/common.py	2006-08-25 08:48:12 UTC (rev 2179)
+++ trunk/Lib/misc/common.py	2006-08-27 07:44:15 UTC (rev 2180)
@@ -9,7 +9,7 @@

from numpy import exp, asarray, arange, \
newaxis, hstack, product, array, where, \
-     zeros, extract, insert, pi, sqrt, eye, poly1d, dot, r_
+     zeros, extract, place, pi, sqrt, eye, poly1d, dot, r_

from numpy import who

@@ -81,8 +81,8 @@
evenn = extract(cond2,n)
nd2o = oddn / 2.0
nd2e = evenn / 2.0
-        insert(vals,cond1,special.gamma(nd2o+1)/sqrt(pi)*pow(2.0,nd2o+0.5))
-        insert(vals,cond2,special.gamma(nd2e+1) * pow(2.0,nd2e))
+        place(vals,cond1,special.gamma(nd2o+1)/sqrt(pi)*pow(2.0,nd2o+0.5))
+        place(vals,cond2,special.gamma(nd2e+1) * pow(2.0,nd2e))
return vals

def factorialk(n,k,exact=1):

Modified: trunk/Lib/signal/waveforms.py
===================================================================
--- trunk/Lib/signal/waveforms.py	2006-08-25 08:48:12 UTC (rev 2179)
+++ trunk/Lib/signal/waveforms.py	2006-08-27 07:44:15 UTC (rev 2180)
@@ -3,7 +3,7 @@
# Author: Travis Oliphant
# 2003

-from numpy import asarray, zeros, insert, nan, mod, pi, extract, log, sqrt, \
+from numpy import asarray, zeros, place, nan, mod, pi, extract, log, sqrt, \
exp, cos, sin, size, polyval, polyint, log10

def sawtooth(t,width=1):
@@ -23,7 +23,7 @@

# width must be between 0 and 1 inclusive
mask1 = (w > 1) | (w < 0)

# take t modulo 2*pi
tmod = mod(t,2*pi)
@@ -33,7 +33,7 @@
-    insert(y,mask2,tsub / (pi*wsub) - 1)
+    place(y,mask2,tsub / (pi*wsub) - 1)

# on the interval width*2*pi to 2*pi function is
#  (pi*(w+1)-tmod) / (pi*(1-w))
@@ -41,7 +41,7 @@
return y

@@ -61,7 +61,7 @@

# width must be between 0 and 1 inclusive
mask1 = (w > 1) | (w < 0)

# take t modulo 2*pi
tmod = mod(t,2*pi)
@@ -71,7 +71,7 @@

# on the interval duty*2*pi to 2*pi function is
#  (pi*(w+1)-tmod) / (pi*(1-w))
@@ -79,7 +79,7 @@
return y

Modified: trunk/Lib/special/basic.py
===================================================================
--- trunk/Lib/special/basic.py	2006-08-25 08:48:12 UTC (rev 2179)
+++ trunk/Lib/special/basic.py	2006-08-27 07:44:15 UTC (rev 2180)
@@ -32,18 +32,18 @@
y = zeros(x.shape,ytype)

mask1 = (n <= 0) | (n <> floor(n))

z = asarray(x / 2.0 / pi)

return y

Modified: trunk/Lib/stats/distributions.py
===================================================================
--- trunk/Lib/stats/distributions.py	2006-08-25 08:48:12 UTC (rev 2179)
+++ trunk/Lib/stats/distributions.py	2006-08-27 07:44:15 UTC (rev 2180)
@@ -13,7 +13,7 @@
ravel, take, ones, sum, shape, product, repeat, reshape, \
zeros, floor, logical_and, log, sqrt, exp, arctanh, tan, sin, arcsin, \
arctan, tanh, ndarray, cos, cosh, sinh, newaxis
-from numpy import atleast_1d, polyval, angle, ceil, insert, extract, \
+from numpy import atleast_1d, polyval, angle, ceil, place, extract, \
any, argsort, argmax, vectorize, r_, asarray, nan, inf, pi, isnan, isinf
import numpy
import numpy.random as mtrand
@@ -461,10 +461,10 @@
cond1 = (scale > 0) & (x > self.a) & (x < self.b)
cond = cond0 & cond1
output = zeros(shape(cond),'d')
goodargs = argsreduce(cond, *((x,)+args+(scale,)))
scale, goodargs = goodargs[-1], goodargs[:-1]
-        insert(output,cond,self._pdf(*goodargs) / scale)
+        place(output,cond,self._pdf(*goodargs) / scale)
return output

def cdf(self,x,*args,**kwds):
@@ -490,10 +490,10 @@
cond2 = (x >= self.b) & cond0
cond = cond0 & cond1
output = zeros(shape(cond),'d')
-        insert(output,cond2,1.0)
+        place(output,cond2,1.0)
goodargs = argsreduce(cond, *((x,)+args))
-        insert(output,cond,self._cdf(*goodargs))
+        place(output,cond,self._cdf(*goodargs))
return output

def sf(self,x,*args,**kwds):
@@ -519,10 +519,10 @@
cond2 = cond0 & (x <= self.a)
cond = cond0 & cond1
output = zeros(shape(cond),'d')
-        insert(output,cond2,1.0)
+        place(output,cond2,1.0)
goodargs = argsreduce(cond, *((x,)+args))
-        insert(output,cond,self._sf(*goodargs))
+        place(output,cond,self._sf(*goodargs))
return output

def ppf(self,q,*args,**kwds):
@@ -547,11 +547,11 @@
cond2 = (q==1) & cond0
cond = cond0 & cond1
output = valarray(shape(cond),value=self.a*scale + loc)
-        insert(output,cond2,self.b*scale + loc)
+        place(output,cond2,self.b*scale + loc)
goodargs = argsreduce(cond, *((q,)+args+(scale,loc)))
scale, loc, goodargs = goodargs[-2], goodargs[-1], goodargs[:-2]
-        insert(output,cond,self._ppf(*goodargs)*scale + loc)
+        place(output,cond,self._ppf(*goodargs)*scale + loc)
return output

def isf(self,q,*args,**kwds):
@@ -576,11 +576,11 @@
cond2 = (q==1) & cond0
cond = cond0 & cond1
output = valarray(shape(cond),value=self.b)
-        insert(output,cond2,self.a)
+        place(output,cond2,self.a)
goodargs = argsreduce(cond, *((1.0-q,)+args+(scale,loc)))
scale, loc, goodargs = goodargs[-2], goodargs[-1], goodargs[:-2]
-        insert(output,cond,self._ppf(*goodargs)*scale + loc)
+        place(output,cond,self._ppf(*goodargs)*scale + loc)
return output

def stats(self,*args,**kwds):
@@ -643,7 +643,7 @@
if mu is None:
mu = self._munp(1.0,*goodargs)
out0 = default.copy()
-            insert(out0,cond,mu*scale+loc)
+            place(out0,cond,mu*scale+loc)
output.append(out0)

if 'v' in moments:
@@ -653,7 +653,7 @@
mu = self._munp(1.0,*goodargs)
mu2 = mu2p - mu*mu
out0 = default.copy()
-            insert(out0,cond,mu2*scale*scale)
+            place(out0,cond,mu2*scale*scale)
output.append(out0)

if 's' in moments:
@@ -667,7 +667,7 @@
mu3 = mu3p - 3*mu*mu2 - mu**3
g1 = mu3 / mu2**1.5
out0 = default.copy()
-            insert(out0,cond,g1)
+            place(out0,cond,g1)
output.append(out0)

if 'k' in moments:
@@ -684,7 +684,7 @@
mu4 = mu4p - 4*mu*mu3 - 6*mu*mu*mu2 - mu**4
g2 = mu4 / mu2**2.0 - 3.0
out0 = default.copy()
-            insert(out0,cond,g2)
+            place(out0,cond,g2)
output.append(out0)

if len(output) == 1:
@@ -780,9 +780,9 @@
args = map(arr,args)
cond0 = self._argcheck(*args) & (scale > 0) & (loc==loc)
output = zeros(shape(cond0),'d')
goodargs = argsreduce(cond0, *args)
-        insert(output,cond0,self.vecentropy(*goodargs)+log(scale))
+        place(output,cond0,self.vecentropy(*goodargs)+log(scale))
return output

_EULER = 0.577215664901532860606512090082402431042  # -special.psi(1)
@@ -2595,25 +2595,25 @@
mu = valarray(shape(b),value=inf)
-            insert(mu, mask, bt / (bt-1.0))
+            place(mu, mask, bt / (bt-1.0))
if 'v' in moments:
mu2 = valarray(shape(b), value=inf)
-            insert(mu2, mask, bt / (bt-2.0) / (bt-1.0)**2)
+            place(mu2, mask, bt / (bt-2.0) / (bt-1.0)**2)
if 's' in moments:
g1 = valarray(shape(b), value=nan)
vals = 2*(bt+1.0)*sqrt(b-2.0)/((b-3.0)*sqrt(b))
if 'k' in moments:
g2 = valarray(shape(b), value=nan)
vals = 6.0*polyval([1.0,1.0,-6,-2],bt)/ \
polyval([1.0,-7.0,12.0,0.0],bt)
return mu, mu2, g1, g2
def _entropy(self, c):
return 1 + 1.0/c - log(c)
@@ -3142,11 +3142,11 @@
xn = 2*pi - xn
yn = tan(xn/2.0)
on = 1.0-1.0/pi*arctan(valn*yn)
-            insert(output, c2, on)
+            place(output, c2, on)
if (any(xp)):
yp = tan(xp/2.0)
op = 1.0/pi*arctan(valp*yp)
-            insert(output, c1, op)
+            place(output, c1, op)
return output
def _ppf(self, q, c):
val = (1.0-c)/(1.0+c)
@@ -3502,9 +3502,9 @@
cond1 = (k >= self.a) & (k <= self.b) & self._nonzero(k,*args)
cond = cond0 & cond1
output = zeros(shape(cond),'d')
goodargs = argsreduce(cond, *((k,)+args))
-        insert(output,cond,self._pmf(*goodargs))
+        place(output,cond,self._pmf(*goodargs))
return output

def cdf(self, k, *args, **kwds):
@@ -3529,10 +3529,10 @@
cond2 = (k >= self.b)
cond = cond0 & cond1
output = zeros(shape(cond),'d')
-        insert(output,cond2*(cond0==cond0), 1.0)
+        place(output,cond2*(cond0==cond0), 1.0)
goodargs = argsreduce(cond, *((k,)+args))
-        insert(output,cond,self._cdf(*goodargs))
+        place(output,cond,self._cdf(*goodargs))
return output

def sf(self,k,*args,**kwds):
@@ -3557,10 +3557,10 @@
cond2 = (k < self.a) & cond0
cond = cond0 & cond1
output = zeros(shape(cond),'d')
-        insert(output,cond2,1.0)
+        place(output,cond2,1.0)
goodargs = argsreduce(cond, *((k,)+args))
-        insert(output,cond,self._sf(*goodargs))
+        place(output,cond,self._sf(*goodargs))
return output

def ppf(self,q,*args,**kwds):
@@ -3584,11 +3584,11 @@
cond2 = (q==1) & cond0
cond = cond0 & cond1
output = valarray(shape(cond),value=self.a-1)
-        insert(output,cond2,self.b)
+        place(output,cond2,self.b)
goodargs = argsreduce(cond, *((q,)+args+(loc,)))
loc, goodargs = goodargs[-1], goodargs[:-1]
-        insert(output,cond,self._ppf(*goodargs) + loc)
+        place(output,cond,self._ppf(*goodargs) + loc)
return output

def isf(self,q,*args,**kwds):
@@ -3613,11 +3613,11 @@
cond2 = (q==1) & cond0
cond = cond0 & cond1
output = valarray(shape(cond),value=self.b)
-        insert(output,cond2,self.a-1)
+        place(output,cond2,self.a-1)
goodargs = argsreduce(cond, *((q,)+args+(loc,)))
loc, goodargs = goodargs[-1], goodargs[:-1]
-        insert(output,cond,self._ppf(*goodargs) + loc)
+        place(output,cond,self._ppf(*goodargs) + loc)
return output

def stats(self, *args, **kwds):
@@ -3673,7 +3673,7 @@
if mu is None:
mu = self._munp(1.0,*goodargs)
out0 = default.copy()
-            insert(out0,cond,mu+loc)
+            place(out0,cond,mu+loc)
output.append(out0)

if 'v' in moments:
@@ -3683,7 +3683,7 @@
mu = self._munp(1.0,*goodargs)
mu2 = mu2p - mu*mu
out0 = default.copy()
-            insert(out0,cond,mu2)
+            place(out0,cond,mu2)
output.append(out0)

if 's' in moments:
@@ -3697,7 +3697,7 @@
mu3 = mu3p - 3*mu*mu2 - mu**3
g1 = mu3 / mu2**1.5
out0 = default.copy()
-            insert(out0,cond,g1)
+            place(out0,cond,g1)
output.append(out0)

if 'k' in moments:
@@ -3714,7 +3714,7 @@
mu4 = mu4p - 4*mu*mu3 - 6*mu*mu*mu2 - mu**4
g2 = mu4 / mu2**2.0 - 3.0
out0 = default.copy()
-            insert(out0,cond,g2)
+            place(out0,cond,g2)
output.append(out0)

if len(output) == 1:
@@ -3779,9 +3779,9 @@
args = map(arr,args)
cond0 = self._argcheck(*args) & (loc==loc)
output = zeros(shape(cond0),'d')
goodargs = argsreduce(cond0, *args)
-        insert(output,cond0,self.vecentropy(*goodargs))
+        place(output,cond0,self.vecentropy(*goodargs))
return output

def __call__(self, *args, **kwds):

Modified: trunk/Lib/stats/stats.py
===================================================================
--- trunk/Lib/stats/stats.py	2006-08-25 08:48:12 UTC (rev 2179)
+++ trunk/Lib/stats/stats.py	2006-08-27 07:44:15 UTC (rev 2180)
@@ -692,7 +692,7 @@
m2 = np.extract(can_correct, m2)
m3 = np.extract(can_correct, m3)
nval = np.sqrt((n-1.0)*n)/(n-2.0)*m3/m2**1.5
-            np.insert(vals, can_correct, nval)
+            np.place(vals, can_correct, nval)
return vals

def kurtosis(a, axis=0, fisher=True, bias=True):
@@ -738,7 +738,7 @@
m2 = np.extract(can_correct, m2)
m4 = np.extract(can_correct, m4)
nval = 1.0/(n-2)/(n-3)*((n*n-1.0)*m4/m2**2.0-3*(n-1)**2.0)
-            np.insert(vals, can_correct, nval+3.0)
+            np.place(vals, can_correct, nval+3.0)
if fisher:
return vals - 3
else:

```