Hyperbolic error area
172444
def as_hyperbola(self, rotated=False):
        
        idx = N.diag_indices(3)
        _ = 1/self.covariance_matrix[idx]
        d = list(_)
        d[-1] *= -1

        arr = N.identity(4)*-1
        arr[idx] = d
        hyp = conic(arr)
        if rotated:
            R = augment(self.axes)
            hyp = hyp.transform(R)
        return hyp
1333571
def pole_error(ax, fit, **kwargs):
    
    ell = normal_errors(fit.axes, fit.covariance_matrix)
    lonlat = -N.array(ell)
    n = len(lonlat)
    codes = [Path.MOVETO]
    codes += [Path.LINETO]*(n-1)
    vertices = list(lonlat)

    plot_patch(ax, vertices, codes, **kwargs)
994695
def _compute_error(self):
        
        # err_i = sum_j R_{k,ij} A_{k,ji} - d_i
        self._err = np.sum(np.multiply(self._R_k, self._C_k.T), axis=0) - self._d
913014
def segment_area(seg):
    '''
    '''
    r0 = seg[0][COLS.R]
    r1 = seg[1][COLS.R]
    h2 = point_dist2(seg[0], seg[1])
    return math.pi * (r0 + r1) * math.sqrt((r0 - r1) ** 2 + h2)
382563
def check_fault_data(cls, edges, mesh_spacing):
        
        if not len(edges) >= 2:
            raise ValueError("at least two edges are required")
        if not all(len(edge) >= 2 for edge in edges):
            raise ValueError("at least two points must be defined "
                             "in each edge")
        if not mesh_spacing > 0.0:
            raise ValueError("mesh spacing must be positive")

        cls.check_surface_validity(edges)
        cls.check_aki_richards_convention(edges)
754598
private void determineGlobalExtremum() {
    alphaExtremum = new double[vec.getDimensionality() - 1];
    for(int n = alphaExtremum.length - 1; n >= 0; n--) {
      alphaExtremum[n] = extremum_alpha_n(n, alphaExtremum);
      if(Double.isNaN(alphaExtremum[n])) {
        throw new IllegalStateException("Houston, we have a problem!\n" + this + "\n" + vec + "\n" + FormatUtil.format(alphaExtremum));
      }
    }

    determineGlobalExtremumType();
  }
1207906
function() {
            var EPS = 1e-5;
            var errors = [];
            if (this.isSelfIntersecting(true)) {
                errors.push("Self intersects");
            }
            var pointcount = {};
            this.sides.map(function(side) {
                function mappoint(p) {
                    var tag = p.x + " " + p.y;
                    if (!(tag in pointcount)) pointcount[tag] = 0;
                    pointcount[tag] ++;
                }
                mappoint(side.vertex0.pos);
                mappoint(side.vertex1.pos);
            });
            for (var tag in pointcount) {
                var count = pointcount[tag];
                if (count & 1) {
                    errors.push("Uneven number of sides (" + count + ") for point " + tag);
                }
            }
            var area = this.area();
            if (area < EPS*EPS) {
                errors.push("Area is " + area);
            }
            if (errors.length > 0) {
                var ertxt = "";
                errors.map(function(err) {
                    ertxt += err + "\n";
                });
                throw new Error(ertxt);
            }
        }
1325393
function(point, area) {
		var epsilon = 1e-6; // 1e-6 is margin in pixels for accumulated error.

		return point.x > area.left - epsilon && point.x < area.right + epsilon &&
			point.y > area.top - epsilon && point.y < area.bottom + epsilon;
	}
627073
def _area(sma, eps, phi, r):
    

    aux = r * math.cos(phi) / sma
    signal = aux / abs(aux)
    if abs(aux) >= 1.:
        aux = signal
    return abs(sma**2 * (1.-eps) / 2. * math.acos(aux))
44716
def deltas(errors, epsilon, mean, std):
    
    below = errors[errors <= epsilon]
    if not len(below):
        return 0, 0

    return mean - below.mean(), std - below.std()
710662
def round_sig_error2(x, ex1, ex2, n):
    ''''''
    minerr = min(ex1,ex2)
    minstex = round_sig(minerr,n)
    if minstex.find('.') < 0:
        extra_zeros = len(minstex) - n
        sigfigs = len(str(int(x))) - extra_zeros
        stx = round_sig(x,sigfigs)
        maxstex = round_sig(max(ex1,ex2),sigfigs)
    else:
        num_after_dec = len(string.split(minstex,'.')[1])
        stx = ("%%.%df" % num_after_dec) % (x)
        maxstex = ("%%.%df" % num_after_dec) % (max(ex1,ex2))
    if ex1 < ex2:
        return stx,minstex,maxstex
    else:
        return stx,maxstex,minstex
1082636
def get_variable_errors(X, L, LX, Z, U, step_g, e_rel, e_abs=0):
    
    n = X.size
    p = Z.size
    e_pri2 = np.sqrt(p)*e_abs/L.spectral_norm + e_rel*np.max([l2(LX), l2(Z)])
    if step_g is not None:
        e_dual2 = np.sqrt(n)*e_abs/L.spectral_norm + e_rel*l2(L.T.dot(U)/step_g)
    else:
        e_dual2 = np.sqrt(n)*e_abs/L.spectral_norm + e_rel*l2(L.T.dot(U))
    return e_pri2, e_dual2
41025
def _compute_errors(self):
        

        try:
            coeffs = fit_first_and_second_harmonics(self.sample.values[0],
                                                    self.sample.values[2])
            covariance = coeffs[1]
            coeffs = coeffs[0]
            model = first_and_second_harmonic_function(self.sample.values[0],
                                                       coeffs)
            residual_rms = np.std(self.sample.values[2] - model)
            errors = np.diagonal(covariance) * residual_rms

            eps = self.sample.geometry.eps
            pa = self.sample.geometry.pa

            # parameter errors result from direct projection of
            # coefficient errors.  These showed to be the error estimators
            # that best convey the errors measured in Monte Carlo
            # experiments (see Busko 1996; ASPC 101, 139).
            ea = abs(errors[2] / self.grad)
            eb = abs(errors[1] * (1. - eps) / self.grad)
            self.x0_err = np.sqrt((ea * np.cos(pa))**2 + (eb * np.sin(pa))**2)
            self.y0_err = np.sqrt((ea * np.sin(pa))**2 + (eb * np.cos(pa))**2)
            self.ellip_err = (abs(2. * errors[4] * (1. - eps) / self.sma /
                                  self.grad))
            if (abs(eps) > np.finfo(float).resolution):
                self.pa_err = (abs(2. * errors[3] * (1. - eps) / self.sma /
                                   self.grad / (1. - (1. - eps)**2)))
            else:
                self.pa_err = 0.
        except Exception:    # we want to catch everything
            self.x0_err = self.y0_err = self.pa_err = self.ellip_err = 0.
630535
private double allowableError(int rank) {
        // NOTE: according to CKMS, this should be count, not size, but this
        // leads
        // to error larger than the error bounds. Leaving it like this is
        // essentially a HACK, and blows up memory, but does "work".
        // int size = count;
        int size = sample.size();
        double minError = size + 1;

        for (Quantile q : quantiles) {
            double error;
            if (rank <= q.quantile * size) {
                error = q.u * (size - rank);
            } else {
                error = q.v * rank;
            }
            if (error < minError) {
                minError = error;
            }
        }

        return minError;
    }
140068
def _ErrorOfDifferences(self, cov, warning_cutoff=1.0e-10):
        

        diag = np.matrix(cov.diagonal())
        d2 = diag + diag.transpose() - 2 * cov

        # Cast warning_cutoff to compare a negative number
        cutoff = -abs(warning_cutoff)

        # check for any numbers below zero.
        if np.any(d2 < 0.0):
            if np.any(d2 < cutoff):
                print("A squared uncertainty is negative. Largest Magnitude = {0:f}".format(
                    abs(np.min(d2[d2 < cutoff]))))
            else:
                d2[np.logical_and(0 > d2, d2 > cutoff)] = 0.0
        return np.sqrt(np.array(d2))
1316092
def bound_perturbed_gmres(pseudo, p, epsilon, deltas):
    '''
    '''
    if not numpy.all(numpy.array(deltas) > epsilon):
        raise ArgumentError('all deltas have to be greater than epsilon')

    bound = []
    for delta in deltas:
        # get boundary paths
        paths = pseudo.contour_paths(delta)

        # get vertices on boundary
        vertices = paths.vertices()

        # evaluate polynomial
        supremum = numpy.max(numpy.abs(p(vertices)))

        # compute bound
        bound.append(epsilon/(delta-epsilon)
                     * paths.length()/(2*numpy.pi*delta)
                     * supremum)
    return bound
272212
private void calculateError(){
        int totalErrorCount = 0;
        int totalRedundancy = 0;
        int trueCoverage = 0;
        int totalCoverage = 0;

        int numNoise = 0;
        double errorNoise = 0;
        double errorNoiseMax = 0;

        double errorMissed = 0;
        double errorMissedMax = 0;

        double errorMisplaced = 0;
        double errorMisplacedMax = 0;

        double totalError = 0.0;
        double totalErrorMax = 0.0;

        /** mainly iterate over all points and find the right error value for the point.
         *  within the same run calculate various other stuff like coverage etc...
         */
        for (int p = 0; p < numPoints; p++) {
            CMMPoint cmdp = gtAnalysis.getPoint(p);
            double weight = cmdp.weight();
            //noise counter
            if(cmdp.isNoise()){
                numNoise++;
                //this is always 1
                errorNoiseMax+=cmdp.connectivity*weight;
            }
            else{
                errorMissedMax+=cmdp.connectivity*weight;
                errorMisplacedMax+=cmdp.connectivity*weight;
            }
            //sum up maxError as the individual errors are the quality weighted between 0-1
            totalErrorMax+=cmdp.connectivity*weight;


            double err = 0;
            int coverage = 0;

            //check every FCluster
            for (int c = 0; c < numFClusters; c++) {
                //contained in cluster c?
                if(pointInclusionProbFC[p][c] >= pointInclusionProbThreshold){
                    coverage++;

                    if(!cmdp.isNoise()){
                        //PLACED CORRECTLY
                        if(matchMap[c] == cmdp.workclass()){
                        }
                        //MISPLACED
                        else{
                            double errvalue = misplacedError(cmdp, c);
                            if(errvalue > err)
                                err = errvalue;
                        }
                    }
                    else{
                        //NOISE
                        double errvalue = noiseError(cmdp, c);
                        if(errvalue > err) err = errvalue;
                    }
                }
            }
            //not in any cluster
            if(coverage == 0){
                //MISSED
                if(!cmdp.isNoise()){
                    err = missedError(cmdp,true);
                    errorMissed+= weight*err;
                }
                //NOISE
                else{
                }
            }
            else{
                if(!cmdp.isNoise()){
                    errorMisplaced+= err*weight;
                }
                else{
                    errorNoise+= err*weight;
                }
            }

            /* processing of other evaluation values */
            totalError+= err*weight;
            if(err!=0)totalErrorCount++;
            if(coverage>0) totalCoverage++;  //points covered by clustering (incl. noise)
            if(coverage>0 && !cmdp.isNoise()) trueCoverage++; //points covered by clustering, don't count noise
            if(coverage>1) totalRedundancy++; //include noise

            cmdp.p.setMeasureValue("CMM",err);
            cmdp.p.setMeasureValue("Redundancy", coverage);
        }

        addValue("CMM", (totalErrorMax!=0)?1-totalError/totalErrorMax:1);
        addValue("CMM Missed", (errorMissedMax!=0)?1-errorMissed/errorMissedMax:1);
        addValue("CMM Misplaced", (errorMisplacedMax!=0)?1-errorMisplaced/errorMisplacedMax:1);
        addValue("CMM Noise", (errorNoiseMax!=0)?1-errorNoise/errorNoiseMax:1);
        addValue("CMM Basic", 1-((double)totalErrorCount/(double)numPoints));

        if(debug){
            System.out.println("-------------");
        }
    }