示例#1
0
 def __init__(self, x, y, nocopy=None):
     if len(x) != len(y): raise ValueError, 'x, y length mismatch!'
     if len(x) < 2: raise ValueError, 'Need at least n=2!'
     # Handle copying first so the datstt call doesn't duplicate
     # any needed conversion of a sequence to an array.
     if nocopy:
         self.x = x
         self.y = y
     else:
         try:
             self.x = x.copy()
             self.y = y.copy()
         except AttributeError:
             self.x, self.y = array(x), array(y)
     self.xbar, self.xstd, self.ybar, self.ystd, \
         self.covar, self.rho, error = _regress.datstt(self.x, self.y)
     if error == 0:
         raise ValueError, 'Input data has zero Sum(x-xbar)(y-ybar)!'
     self.xstd = sqrt(self.xstd)
     self.ystd = sqrt(self.ystd)
示例#2
0
 def __init__(self, x, y, nocopy=None):
     if len(x) != len(y): raise ValueError, 'x, y length mismatch!'
     if len(x) < 2: raise ValueError, 'Need at least n=2!'
     # Handle copying first so the datstt call doesn't duplicate
     # any needed conversion of a sequence to an array.
     if nocopy:
         self.x = x
         self.y = y
     else:
         try:
             self.x = x.copy()
             self.y = y.copy()
         except AttributeError:
             self.x, self.y = array(x), array(y)
     self.xbar, self.xstd, self.ybar, self.ystd, \
         self.covar, self.rho, error = _regress.datstt(self.x, self.y)
     if error == 0:
         raise ValueError, 'Input data has zero Sum(x-xbar)(y-ybar)!'
     self.xstd = sqrt(self.xstd)
     self.ystd = sqrt(self.ystd)
示例#3
0
def bistats(x, y):
    """
    Basic statistics summarizing a bivariate distribution.
    
    xbar, xstd, ybar, ystd, covar, rho = bistats(x,y)
    
    xbar, ybar are the sample means
    xstd, ystd are the sample standard deviations (with 1/n
        rather than 1/(n-1) factors in the variance sum)
    covar is the covariance
    rho is Pearson's linear correlation coefficient
    """
    if len(x) != len(y): raise ValueError, 'x, y length mismatch!'
    if len(x) < 2: raise ValueError, 'Need at least n=2!'
    xbar, xstd, ybar, ystd, covar, rho, ierr = _regress.datstt(x, y)
    if ierr == 0:
        raise ValueError, 'Input data has zero Sum(x-xbar)(y-ybar)!'
    xstd = sqrt(xstd)
    ystd = sqrt(ystd)
    return xbar, xstd, ybar, ystd, covar, rho
示例#4
0
def bistats(x, y):
    """
    Basic statistics summarizing a bivariate distribution.
    
    xbar, xstd, ybar, ystd, covar, rho = bistats(x,y)
    
    xbar, ybar are the sample means
    xstd, ystd are the sample standard deviations (with 1/n
        rather than 1/(n-1) factors in the variance sum)
    covar is the covariance
    rho is Pearson's linear correlation coefficient
    """
    if len(x) != len(y): raise ValueError, 'x, y length mismatch!'
    if len(x) < 2: raise ValueError, 'Need at least n=2!'
    xbar, xstd, ybar, ystd, covar, rho, ierr = _regress.datstt(x,y)
    if ierr == 0:
        raise ValueError, 'Input data has zero Sum(x-xbar)(y-ybar)!'
    xstd = sqrt(xstd)
    ystd = sqrt(ystd)
    return xbar, xstd, ybar, ystd, covar, rho