core dump

Chad Scherrer chscherr at indiana.edu
Wed Oct 6 19:53:03 EDT 1999


I'm using Python 1.5.2 in Red Hat 6.0, and am getting a core dump.
Here's the code:
____________________________________________________________________

from random import gauss
import Numeric; N=Numeric
import LinearAlgebra; LA=LinearAlgebra
import ranlib
from math import pi
TWOPI=2.0*pi

def stdnormal(shape=[]):
    if type(shape) == type(0): shape = [shape]
    n = Numeric.multiply.reduce(shape)

    x = TWOPI*ranlib.sample(n/2)
    y = Numeric.sqrt(-2*Numeric.log(ranlib.sample(n/2)))
    (x,y)=(Numeric.cos(x)*y,Numeric.sin(x)*y)

    if len(shape) != 0:
        return Numeric.reshape((x,y), shape)
    else:
         return x[0]

def altnorm(mu1,mu2,n):
    z = stdnormal([n,3])
    for zn in z:
        zn[2] = mu1 * zn[0] + mu2 * zn[1] + zn[2]
    return z

def genS(mu1,mu2,n):
    X = altnorm(mu1,mu2,n)
    return N.dot(N.transpose(X),X)/n

def genPsi(mu1,mu2,n):
    S = genS(mu1,mu2,n)

    a = N.dot(S[2,:2],LA.inverse(S[:2,:2]))
    b=N.array(S[0,0],S[1,1])

    return (a,b)
_____________________________________________________________

The core dump happens when I import this module and then try something
like
Psi=genPsi(3,3,6). Is this a bug in Python, or am I doing something
wrong? Thanks in advance.
-Chad





More information about the Python-list mailing list