给定卡方分布的p值和自由度，返回卡方值。内部采用二分搜索实现，移植自JS代码：
http://www.fourmilab.ch/rpkp/experiments/analysis/chiCalc.js

@param p  p值（置信度）
@param df
@return
434318
public static double ChisquareInverseCdf(double p, int df)
    {
        final double CHI_EPSILON = 0.000001;   /* Accuracy of critchi approximation */
        final double CHI_MAX = 99999.0;        /* Maximum chi-square value */
        double minchisq = 0.0;
        double maxchisq = CHI_MAX;
        double chisqval = 0.0;

        if (p <= 0.0)
        {
            return CHI_MAX;
        }
        else if (p >= 1.0)
        {
            return 0.0;
        }

        chisqval = df / Math.sqrt(p);    /* fair first value */
        while ((maxchisq - minchisq) > CHI_EPSILON)
        {
            if (1 - ChisquareCdf(chisqval, df) < p)
            {
                maxchisq = chisqval;
            }
            else
            {
                minchisq = chisqval;
            }
            chisqval = (maxchisq + minchisq) * 0.5;
        }

        return chisqval;
    }
97672
public double[] dataVector(V p) {
    return strongEigenvectors.length > 0 ? times(strongEigenvectors, transposeTimes(strongEigenvectors, minusEquals(p.toArray(), centroid))) : EMPTY_VECTOR;
  }
489784
private function _p() {
		$c = $this->_c; /** @var C $c */
		$c->setHeaders($this->headers());
		$c->setUri($this->url());
		try {
			$res = $c->request(); /** @var \Zend_Http_Response $res */
			if (!($resBody = $res->getBody()) && $res->isError()) { /** @var string $resBody */
				throw new eHTTP($res);
			}
			else {
				/** @var mixed|null $result */
				// 2017-08-08
				// «No Content»
				// «The server has successfully fulfilled the request
				// and that there is no additional content to send in the response payload body»
				// https://httpstatuses.com/204
				if (!$resBody && 204 === $res->getStatus()) {
					$result = null;
				}
				else {
					$result = $this->_filtersResBV->filter($resBody);
					if ($validatorC = $this->responseValidatorC() /** @var string $validatorC */) {
						$validator = new $validatorC($result); /** @var Validator $validator */
						if (!$validator->valid()) {
							throw $validator;
						}
					}
					$result = $this->_filtersResAV->filter($result);
				}
			}
		}
		catch (\Exception $e) {
			/** @var string $long */ /** @var string $short */
			list($long, $short) = $e instanceof E ? [$e->long(), $e->short()] : [null, df_ets($e)];
			$req = df_zf_http_last_req($c); /** @var string $req */
			$title = df_api_name($m = df_module_name($this)); /** @var string $m */ /** @var string $title */
			$ex = df_error_create("A `{$this->_path}` {$title} API request has failed: «{$short}».\n" . (
				$long === $short ? "Request:\n{$req}" : df_cc_kv([
					'The full error description' => $long, 'Request' => $req
				])
			)); /** @var DFE $ex */
			df_log_l($m, $ex);
			df_sentry($m, $short, ['extra' => ['Request' => $req, 'Response' => $long]]);
			throw $ex;
		}
		return $result;
	}
10949
public boolean forEachPartition(IterateProcedure<E> p) {
        int curIdx = index.get(values.get(0).id());
        int from;
        int to;
        for (from = 0, to = 0; to < values.size(); to++) {
            int cIdx = index.get(values.get(to).id());
            if (curIdx != cIdx) {
                if (!p.extract(this, curIdx, from, to)) {
                    return false;
                }
                from = to;
                curIdx = cIdx;
            }
        }
        return p.extract(this, curIdx, from, to);
    }
694253
public static double getPvalue(DataTable2D dataTable) {

        AssociativeArray result = getScore(dataTable);
        double score = result.getDouble("score");
        int n = result.getDouble("n").intValue();
        int k = result.getDouble("k").intValue();
        
        double pvalue = scoreToPvalue(score, n, k);

        return pvalue;
    }
1027148
public static double Euclidean(IntPoint p, IntPoint q) {
        return Euclidean(p.x, p.y, q.x, q.y);
    }
113064
function pmf( x, p ) {
	var q;
	if ( x !== x) {
		return NaN;
	}
	if ( isNonNegativeInteger( x ) ) {
		q = 1 - p;
		return p * pow( q, x );
	}
	return 0;
}
1340560
public static double gaussInverseCdf(double p) {
        final double P_LOW  = 0.02425D;
        final double P_HIGH = 1.0D - P_LOW;
        final double ICDF_A[] =
            { -3.969683028665376e+01,  2.209460984245205e+02,
              -2.759285104469687e+02,  1.383577518672690e+02,
              -3.066479806614716e+01,  2.506628277459239e+00 };
        final double ICDF_B[] =
            { -5.447609879822406e+01,  1.615858368580409e+02,
              -1.556989798598866e+02,  6.680131188771972e+01,
              -1.328068155288572e+01 };
        final double ICDF_C[] =
            { -7.784894002430293e-03, -3.223964580411365e-01,
              -2.400758277161838e+00, -2.549732539343734e+00,
              4.374664141464968e+00,  2.938163982698783e+00 };
        final double ICDF_D[] =
            { 7.784695709041462e-03,  3.224671290700398e-01,
              2.445134137142996e+00,  3.754408661907416e+00 };
        
        // Define break-points.
        // variable for result
        double z;

        if(p == 0) {
            z = Double.NEGATIVE_INFINITY;
        }
        else if(p == 1) {
            z = Double.POSITIVE_INFINITY;
        }
        else if(Double.isNaN(p) || p < 0 || p > 1) {
            z = Double.NaN;
        }
        else if( p < P_LOW ) { // Rational approximation for lower region:
          double q  = Math.sqrt(-2*Math.log(p));
          z = (((((ICDF_C[0]*q+ICDF_C[1])*q+ICDF_C[2])*q+ICDF_C[3])*q+ICDF_C[4])*q+ICDF_C[5]) / ((((ICDF_D[0]*q+ICDF_D[1])*q+ICDF_D[2])*q+ICDF_D[3])*q+1);
        }
        else if ( P_HIGH < p ) { // Rational approximation for upper region:
          double q  = Math.sqrt(-2*Math.log(1-p));
          z = -(((((ICDF_C[0]*q+ICDF_C[1])*q+ICDF_C[2])*q+ICDF_C[3])*q+ICDF_C[4])*q+ICDF_C[5]) / ((((ICDF_D[0]*q+ICDF_D[1])*q+ICDF_D[2])*q+ICDF_D[3])*q+1);
        } 
        else { // Rational approximation for central region:
          double q = p - 0.5D;
          double r = q * q;
          z = (((((ICDF_A[0]*r+ICDF_A[1])*r+ICDF_A[2])*r+ICDF_A[3])*r+ICDF_A[4])*r+ICDF_A[5])*q / (((((ICDF_B[0]*r+ICDF_B[1])*r+ICDF_B[2])*r+ICDF_B[3])*r+ICDF_B[4])*r+1);
        }
        
        return z;
    }
500265
public static TableModel fromCSP(CSProperties p, final int dim) {
        List<String> dims = keysByMeta(p, "role", "dimension");
        if (dims.isEmpty()) {
            return null;
        }
        for (String d : dims) {
            if (Integer.parseInt(p.get(d).toString()) == dim) {
                final List<String> bounds = keysByMeta(p, "bound", d);
                final List<Object> columns = new ArrayList<Object>(bounds.size());
                for (String bound : bounds) {
                    columns.add(Conversions.convert(p.get(bound), double[].class));
                }

                return new AbstractTableModel() {

                    @Override
                    public int getRowCount() {
                        return dim;
                    }

                    @Override
                    public int getColumnCount() {
                        return bounds.size();
                    }

                    @Override
                    public Object getValueAt(int rowIndex, int columnIndex) {
                        return Array.get(columns.get(columnIndex), rowIndex);
                    }

                    @Override
                    public String getColumnName(int column) {
                        return bounds.get(column);
                    }

                    @Override
                    public Class<?> getColumnClass(int columnIndex) {
                        return Double.class;
                    }
                };
            }
        }
        return null;
    }
384947
function calcProp(ka, p) {
  var val = ka[p];
  if (isKeepAssigned(val)) {
    recalc(val);
  } else {
    val.val = findFirstProp(ka.objs, p);
  }
}
1246992
function(p) {
            var m = this.m;
            return {
                x: m[0] * p.x + m[2] * p.y + m[4],
                y: m[1] * p.x + m[3] * p.y + m[5]
            };
        }
308578
public static double dirichletPdf(double[] pi, double[] ai) {
        double probability=1.0;
        double sumAi=0.0;
        double productGammaAi=1.0;
        
        double tmp;
        int piLength=pi.length;
        for(int i=0;i<piLength;++i) {
            tmp=ai[i];
            sumAi+= tmp;
            productGammaAi*=gamma(tmp);
            probability*=Math.pow(pi[i], tmp-1);
        }
        
        probability*=gamma(sumAi)/productGammaAi;
        
        return probability;
    }
1256962
function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {
		return	this._checkCounterclockwise(p, p2, p3) !==
				this._checkCounterclockwise(p1, p2, p3) &&
				this._checkCounterclockwise(p, p1, p2) !==
				this._checkCounterclockwise(p, p1, p3);
	}
1257640
public static AbstractTableModel getProperties(final CSProperties p) {

        return new AbstractTableModel() {

            @Override
            public int getRowCount() {
                return p.keySet().size();
            }

            @Override
            public int getColumnCount() {
                return 2;
            }

            @Override
            public Object getValueAt(int rowIndex, int columnIndex) {
                if (columnIndex == 0) {
                    return " " + p.keySet().toArray()[rowIndex];
                } else {
                    return p.values().toArray()[rowIndex];
                }
            }

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return columnIndex == 1;
            }

            @Override
            public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
                if (columnIndex == 1) {
                    String[] keys = p.keySet().toArray(new String[0]);
                    p.put(keys[rowIndex], aValue.toString());
                }
            }

            @Override
            public String getColumnName(int column) {
                return column == 0 ? "Name" : "Value";
            }

            @Override
            public Class<?> getColumnClass(int columnIndex) {
                return String.class;
            }
        };
    }
1011383
private int samplePMF(double p[]) {

        double r = m_MetaRandom.nextDouble();

        double sum = 0.0;
        for (int i = 0; i < p.length; i++) {
            sum += p[i];
            if (r < sum) {
                return i;
            }
        }
        return -1;
    }
842966
@GwtIncompatible("TODO")
  public static BigInteger divide(BigInteger p, BigInteger q, RoundingMode mode) {
    BigDecimal pDec = new BigDecimal(p);
    BigDecimal qDec = new BigDecimal(q);
    return pDec.divide(qDec, 0, mode).toBigIntegerExact();
  }
1304155
public SortedClassProbability[] sortByDescendingClassProbability(BinomialModelPrediction p) {
    String[] domainValues = m.getDomainValues(m.getResponseIdx());
    double[] classProbabilities = p.classProbabilities;
    return sortByDescendingClassProbability(domainValues, classProbabilities);
  }