PEATDB/Ekin/Fitting.py
def checkforOutliers(olddata, oldfitdata):
    """
    It may happen that the simpler fit has a lower error than
    the more complex model because of far outliers, so we check this
    by removing any outliers. (We get stdev of datapoints and see if
    each datapoint is within 3 stdevs of fit curve).
    Then fit again and see if error is better.
    see http://www.graphpad.com/help/prism5/prism5help.html?reg_oultlier_2.htm
    """

    print 'Checking for outliers'
    x=[]
    #we don't want to overwrite the datapoints to avoid confusion
    import copy
    newdata = copy.deepcopy(olddata)

    #xd,yd,a = EkinConvert.ekin2xy(olddata)
    xd,yd = oldata.getxy()
    expdata = zip(xd,yd)
    mean,stdev = Utils.meanstdv(yd)
    print 'meanstdv:',mean,stdev
    for i in range(0,newdata.length()):
        y=newdata.y[i]
    if y>=mean+stdev*2 or y<mean-stdev*2:        
        print y,':point is an outlier?'
        newdata.active[i] = 0

    model = oldfitdata['model']
    olderror = oldfitdata['error']
    #newfit = self.fitDataset(datatofit, oldfitdata, model=model)
    newfit, X = doFit(newdata, model=model)
    newerror = float(newfit['error'])
    return newerror, newfit

    It may happen that the simpler fit has a lower error than
    the more complex model because of far outliers, so we check this
    by removing any outliers. (We get stdev of datapoints and see if
    each datapoint is within 3 stdevs of fit curve).
    Then fit again and see if error is better.
    see http://www.graphpad.com/help/prism5/prism5help.html?reg_oultlier_2.htm
    
It may happen that the simpler fit has a lower error than
the more complex model because of far outliers, so we check this
by removing any outliers. (We get stdev of datapoints and see if
each datapoint is within 3 stdevs of fit curve).
Then fit again and see if error is better.
It may happen that the simpler fit has a lower error than the more complex model because of far outliers so we check this by removing any outliers . ( We get stdev of datapoints and see if each datapoint is within 3 stdevs of fit curve ) . Then fit again and see if error is better .
def checkforOutliers(olddata, oldfitdata):
    print 'Checking for outliers'
    x=[]
    import copy
    newdata = copy.deepcopy(olddata)
    xd,yd = oldata.getxy()
    expdata = zip(xd,yd)
    mean,stdev = Utils.meanstdv(yd)
    print 'meanstdv:',mean,stdev
    for i in range(0,newdata.length()):
        y=newdata.y[i]
    if y>=mean+stdev*2 or y<mean-stdev*2:        
        print y,':point is an outlier?'
        newdata.active[i] = 0
    model = oldfitdata['model']
    olderror = oldfitdata['error']
    newfit, X = doFit(newdata, model=model)
    newerror = float(newfit['error'])
    return newerror, newfit
def checkforOutliers ( olddata , oldfitdata ) : print 'Checking for outliers' x = [ ] import copy newdata = copy . deepcopy ( olddata ) xd , yd = oldata . getxy ( ) expdata = zip ( xd , yd ) mean , stdev = Utils . meanstdv ( yd ) print 'meanstdv:' , mean , stdev for i in range ( 0 , newdata . length ( ) ) : y = newdata . y [ i ] if y >= mean + stdev * 2 or y < mean - stdev * 2 : print y , ':point is an outlier?' newdata . active [ i ] = 0 model = oldfitdata [ 'model' ] olderror = oldfitdata [ 'error' ] newfit , X = doFit ( newdata , model = model ) newerror = float ( newfit [ 'error' ] ) return newerror , newfit
It may happen that the simpler fit has a lower error than
the more complex model because of far outliers, so we check this
by removing any outliers.
It may happen that the simpler fit has a lower error than the more complex model because of far outliers so we check this by removing any outliers .
"""
    It may happen that the simpler fit has a lower error than
    the more complex model because of far outliers, so we check this
    by removing any outliers. (We get stdev of datapoints and see if
    each datapoint is within 3 stdevs of fit curve).
    Then fit again and see if error is better.
    see http://www.graphpad.com/help/prism5/prism5help.html?reg_oultlier_2.htm
    """ #we don't want to overwrite the datapoints to avoid confusion #xd,yd,a = EkinConvert.ekin2xy(olddata) #newfit = self.fitDataset(datatofit, oldfitdata, model=model)
olddata
oldfitdata