Package org.apache.commons.math3.distribution

Examples of org.apache.commons.math3.distribution.ExponentialDistribution


  @Override
  @Deprecated
  public ImmutableList<Double> generate(RandomGenerator rng) {
    // we model the announcements as a Poisson process, which means that
    // the interarrival times are exponentially distributed.
    final ExponentialDistribution ed = new ExponentialDistribution(1d / gai);
    ed.reseedRandomGenerator(rng.nextLong());
    double sum = 0;
    final List<Double> arrivalTimes = newArrayList();
    while (sum < length) {
      // final long nt = DoubleMath
      // .roundToLong(ed.sample() * 60d, RoundingMode.HALF_DOWN);

      // ignore values which are smaller than the time unit (one
      // minute), unless its the first value.
      // if (/*nt > 0 ||*/ arrivalTimes.isEmpty()) {
      sum += ed.sample() * 60d;
      if (sum < length) {
        arrivalTimes.add(sum);
      } else if (arrivalTimes.isEmpty()) {
        // there is a small probability where the first
        // generated arrival time is greater than length. This
View Full Code Here


    lambdaMax = lambda.getMax();
  }

  @Override
  public ImmutableList<Double> generate(RandomGenerator rng) {
    final ExponentialDistribution ed = new ExponentialDistribution(rng,
        1d / lambdaMax,
        ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    double sum = 0d;

    final ImmutableList.Builder<Double> builder = ImmutableList.builder();
    while (sum < length) {
      sum += ed.sample();
      if (sum < length && rng.nextDouble() <= (lambd.apply(sum) / lambdaMax)) {
        builder.add(sum);
      }
    }
    return builder.build();
View Full Code Here

         */
        double[] quartiles;
        long[] counts;

        // Mean 1
        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(1));
        counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextExponential(1);
            TestUtils.updateCounts(value, counts, quartiles);
        }
        TestUtils.assertChiSquareAccept(expected, counts, 0.001);

        // Mean 5
        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(5));
        counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextExponential(5);
            TestUtils.updateCounts(value, counts, quartiles);
View Full Code Here

     * length.
     */
    protected double[] computeResiduals(double[] objectiveValue) {
        final double[] target = getTarget();
        if (objectiveValue.length != target.length) {
            throw new DimensionMismatchException(target.length,
                                                 objectiveValue.length);
        }

        final double[] residuals = new double[target.length];
        for (int i = 0; i < target.length; i++) {
View Full Code Here

        /** {@inheritDoc} */
        public RealVector solve(final RealVector b) {
            final int m = lTData.length;
            if (b.getDimension() != m) {
                throw new DimensionMismatchException(b.getDimension(), m);
            }

            final double[] x = b.toArray();

            // Solve LY = b
View Full Code Here

        /** {@inheritDoc} */
        public RealMatrix solve(RealMatrix b) {
            final int m = lTData.length;
            if (b.getRowDimension() != m) {
                throw new DimensionMismatchException(b.getRowDimension(), m);
            }

            final int nColB = b.getColumnDimension();
            final double[][] x = b.getData();

View Full Code Here

     */
    public double correlation(final double[] xArray, final double[] yArray)
            throws DimensionMismatchException {

        if (xArray.length != yArray.length) {
            throw new DimensionMismatchException(xArray.length, yArray.length);
        }

        final int n = xArray.length;
        final long numPairs = sum(n - 1);

View Full Code Here

     * @throws DimensionMismatchException if {@link #target} and
     * {@link #weightMatrix} have inconsistent dimensions.
     */
    private void checkParameters() {
        if (target.length != weightMatrix.getColumnDimension()) {
            throw new DimensionMismatchException(target.length,
                                                 weightMatrix.getColumnDimension());
        }
    }
View Full Code Here

    public void increment(final double[] data)
        throws DimensionMismatchException {

        int length = data.length;
        if (length != dimension) {
            throw new DimensionMismatchException(length, dimension);
        }

        // only update the upper triangular part of the covariance matrix
        // as only these parts are actually stored
        for (int i = 0; i < length; i++){
View Full Code Here

     * @throws DimensionMismatchException if the dimension of sc does not match this
     * @since 3.3
     */
    public void append(StorelessCovariance sc) throws DimensionMismatchException {
        if (sc.dimension != dimension) {
            throw new DimensionMismatchException(sc.dimension, dimension);
        }

        // only update the upper triangular part of the covariance matrix
        // as only these parts are actually stored
        for (int i = 0; i < dimension; i++) {
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.distribution.ExponentialDistribution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.