Cumulative density function.

@param val Value
@param shape Shape
@param location Location
@param scale Scale
@return CDF
545223
public static double cdf(double val, double shape, double location, double scale) {
    if(val < location) {
      return 0;
    }
    val = (val - location) / scale;
    return 1. / (1. + FastMath.pow(val, -shape));
  }
665477
public static double pdf(double x, double mu, double shape) {
    if(!(x > 0) || x == Double.POSITIVE_INFINITY) {
      return x == x ? 0 : Double.NaN;
    }
    final double v = (x - mu) / mu;
    double t1 = FastMath.sqrt(shape / (MathUtil.TWOPI * x * x * x));
    return t1 > 0 ? t1 * FastMath.exp(-shape * v * v * .5 / x) : 0;
  }
82123
@Override
    public INDArray rand(int[] shape, Distribution r) {
        INDArray ret = r.sample(shape);
        return ret;
    }
667967
public static double pdf(double val, double loc, double scale, double shape) {
    val = (val - loc) / scale;
    if(shape != 0.) {
      val = -FastMath.log(1 - shape * val) / shape;
    }
    double f = 1. + FastMath.exp(-val);
    return FastMath.exp(-val * (1 - shape)) / (scale * f * f);
  }
842066
public static double quantile(double val, double loc, double scale, double shape1, double shape2) {
    if(!(val >= 0.) || !(val <= 1.)) {
      return Double.NaN;
    }
    if(val == 0.) {
      if(shape2 <= 0.) {
        return shape1 < 0. ? loc + scale / shape1 : Double.NEGATIVE_INFINITY;
      }
      else {
        return loc + (shape1 != 0. //
            ? scale / shape1 * (1. - FastMath.pow(shape2, -shape1)) //
            : scale * FastMath.log(shape2));
      }
    }
    if(val == 1.) {
      return shape1 <= 0. ? Double.NEGATIVE_INFINITY : loc + scale / shape1;
    }
    val = -FastMath.log(val);
    if(shape2 != 0.) {
      val = (1 - FastMath.exp(-shape2 * val)) / shape2;
    }
    val = -FastMath.log(val);
    if(shape1 != 0.) {
      val = (1 - FastMath.exp(-shape1 * val)) / shape1;
    }
    return loc + scale * val;
  }
546076
public static KmeansDataSet createDataModel(List<KmeansPoint> pointList, int clusterNum,
            int maxIteration, double convergenceThres)
    {
        // クラスタ数よりもデータ数が少ない場合、結果はnullとして返す。
        if (pointList.size() < clusterNum)
        {
            return null;
        }

        // 初回の中心点リストを生成する。
        List<KmeansPoint> centroids = createInitialCentroids(pointList, clusterNum);
        long[] clusteredNum = new long[clusterNum];

        // イテレーションを最大回数実行し、収束を試みる。
        for (int exeIndex = 0; exeIndex < maxIteration; exeIndex++)
        {
            Map<Integer, List<KmeansPoint>> assignments = Maps.newHashMap();
            for (int centroidIndex = 0; centroidIndex < clusterNum; centroidIndex++)
            {
                assignments.put(centroidIndex, Lists.<KmeansPoint> newArrayList());
            }

            for (KmeansPoint targetPoint : pointList)
            {
                KmeansResult result = nearestCentroid(targetPoint, centroids);
                assignments.get(result.getCentroidIndex()).add(targetPoint);
            }

            List<KmeansPoint> newCentroids = Lists.newArrayList();
            for (Map.Entry<Integer, List<KmeansPoint>> entry : assignments.entrySet())
            {
                if (entry.getValue().isEmpty())
                {
                    newCentroids.add(centroids.get(entry.getKey()));
                }
                else
                {
                    newCentroids.add(calculateCentroid(entry.getValue()));
                }

                clusteredNum[entry.getKey()] = entry.getValue().size();
            }

            boolean isConvergenced = isConvergenced(centroids, newCentroids, convergenceThres);
            centroids = newCentroids;

            if (isConvergenced == true)
            {

                break;
            }
        }

        double[][] centroidPoints = new double[clusterNum][];

        for (int centroidIndex = 0; centroidIndex < clusterNum; centroidIndex++)
        {
            centroidPoints[centroidIndex] = centroids.get(centroidIndex).getDataPoint();
        }

        KmeansDataSet createdModel = new KmeansDataSet();
        createdModel.setCentroids(centroidPoints);
        createdModel.setClusteredNum(clusteredNum);
        return createdModel;
    }
25572
public T divide( double val ) {
        T ret = createLike();
        ops.divide(mat,val,ret.getMatrix());
        return ret;
    }
686924
public static double cdf(double val, double mu, double sigma, double k) {
    final double x = (val - mu) / sigma;
    if(k > 0 || k < 0) {
      if(k * x > 1) {
        return k > 0 ? 1 : 0;
      }
      return FastMath.exp(-FastMath.exp(FastMath.log(1 - k * x) / k));
    }
    else { // Gumbel case:
      return FastMath.exp(-FastMath.exp(-x));
    }
  }
345146
public T scale( double val ) {
        T ret = createLike();
        ops.scale(mat,val,ret.getMatrix());
        return ret;
    }
765477
public static double quantile(double val, double k, double lambda, double theta) {
    if(val < 0.0 || val > 1.0) {
      return Double.NaN;
    }
    else if(val == 0) {
      return 0.0;
    }
    else if(val == 1) {
      return Double.POSITIVE_INFINITY;
    }
    else {
      return theta + lambda * FastMath.pow(-FastMath.log(1.0 - val), 1.0 / k);
    }
  }
643253
public static double cdf(double val, int v) {
    double x = v / (val * val + v);
    return 1 - (0.5 * BetaDistribution.regularizedIncBeta(x, v * .5, 0.5));
  }
1034431
public static double cdf(double val, double k, double lambda, double theta) {
    return (val > theta) ? //
        (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) //
        : val == val ? 0.0 : Double.NaN;
  }
182332
public static double cdf(double x, double mu, double sigma) {
    if(x <= 0.) {
      return 0.;
    }
    return .5 * (1 + NormalDistribution.erf((FastMath.log(x) - mu) / (MathUtil.SQRT2 * sigma)));
  }
1191185
public static double cdf(double val, double dof) {
    double v = val * val * .5;
    // regularizedGammaP will return NaN for infinite values!
    return val < 0. ? 0. : v < Double.POSITIVE_INFINITY ? GammaDistribution.regularizedGammaP(dof * .5, v) : v == v ? 1. : Double.NaN;
  }
513569
public static double cdf(double x, double sigma) {
    if(x <= 0.) {
      return 0.;
    }
    final double xs = x / sigma;
    return 1. - FastMath.exp(-.5 * xs * xs);
  }
1291950
public void orizzonte7( double delta, int quadrata, double beta, double alfa, RandomIter elevImageIterator,
            WritableRaster curvatureImage, int[][] shadow ) {
        int rows = curvatureImage.getHeight();
        int cols = curvatureImage.getWidth();
        /*=====================*/

        int y, I, J;
        double zenith;

        /*======================*/

        for( int i = quadrata - 1; i >= 0; i-- ) {
            I = -1;
            J = -1;
            y = 0;
            for( int ii = i; ii < quadrata - 1; ii++ ) {
                for( int j = (int) floor(1 / tan(beta) * (ii - i)); j <= (int) floor(1 / tan(beta) * (ii - i + 1)) - 1
                        && j < cols; j++ ) {
                    if (ii >= (rows + 2 * cols) && !isNovalue(elevImageIterator.getSampleDouble(j, ii - (rows + 2 * cols), 0))) {
                        /*shadow.element[ii-(Z0.nrh+2*Z0.nch)][j]=i;}}}}*/
                        if (curvatureImage.getSampleDouble(j, ii - (rows + 2 * cols), 0) == 1 && I == -1) {
                            I = ii - (rows + 2 * cols);
                            J = j;
                            y = 1;
                        } else if (curvatureImage.getSampleDouble(j, ii - (rows + 2 * cols), 0) == 1 && I != -1) {
                            zenith = (elevImageIterator.getSampleDouble(J, I, 0) - elevImageIterator.getSampleDouble(j, ii
                                    - (rows + 2 * cols), 0))
                                    / sqrt(pow((double) (I - (ii - (rows + 2 * cols))) * (double) delta, (double) 2)
                                            + pow((double) (J - j) * (double) delta, (double) 2));
                            if (zenith <= tan(alfa)) {
                                shadow[ii - (rows + 2 * cols)][j] = 0;
                                I = ii - (rows + 2 * cols);
                                J = j;
                            } else {
                                shadow[ii - (rows + 2 * cols)][j] = 1;
                            }
                        } else if (curvatureImage.getSampleDouble(j, ii - (rows + 2 * cols), 0) == 0 && y == 1) {
                            zenith = (elevImageIterator.getSampleDouble(J, I, 0) - elevImageIterator.getSampleDouble(j, ii
                                    - (rows + 2 * cols), 0))
                                    / sqrt(pow((double) (I - (ii - (rows + 2 * cols))) * (double) delta, (double) 2)
                                            + pow((double) (J - j) * (double) delta, (double) 2));
                            if (zenith <= tan(alfa)) {
                                shadow[ii - (rows + 2 * cols)][j] = 0;
                                y = 0;
                            } else {
                                shadow[ii - (rows + 2 * cols)][j] = 1;
                            }
                        }
                    }
                }
            }
        }

    }
892568
public static double pdf(double val, double loc, double scale, double shape) {
    if(!(val < Double.POSITIVE_INFINITY && val > Double.NEGATIVE_INFINITY)) {
      return val == val ? 0. : Double.NaN;
    }
    val = (val - loc) / scale;
    double e = FastMath.exp(-val);
    double f = 1. + e;
    return e < Double.POSITIVE_INFINITY ? shape * e / (scale * FastMath.pow(f, shape + 1.)) : 0.;
  }