Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1490917843 for ; Sat, 18 Oct 2014 20:11:39 +0000 (UTC) Received: (qmail 45585 invoked by uid 500); 18 Oct 2014 20:11:38 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 45512 invoked by uid 500); 18 Oct 2014 20:11:38 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 45503 invoked by uid 99); 18 Oct 2014 20:11:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2014 20:11:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Oct 2014 20:11:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C3B462388BF1 for ; Sat, 18 Oct 2014 20:10:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r926176 [8/31] - in /websites/production/commons/content/proper/commons-math: apidocs/org/apache/commons/math3/analysis/interpolation/ apidocs/org/apache/commons/math3/analysis/interpolation/class-use/ apidocs/org/apache/commons/math3/distr... Date: Sat, 18 Oct 2014 20:10:40 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141018201046.C3B462388BF1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/analysis/interpolation/AkimaSplineInterpolator.html ============================================================================== --- websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/analysis/interpolation/AkimaSplineInterpolator.html (added) +++ websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/analysis/interpolation/AkimaSplineInterpolator.html Sat Oct 18 20:10:38 2014 @@ -0,0 +1,297 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017package org.apache.commons.math3.analysis.interpolation;
+018
+019import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
+020import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction;
+021import org.apache.commons.math3.exception.DimensionMismatchException;
+022import org.apache.commons.math3.exception.NonMonotonicSequenceException;
+023import org.apache.commons.math3.exception.NullArgumentException;
+024import org.apache.commons.math3.exception.NumberIsTooSmallException;
+025import org.apache.commons.math3.exception.util.LocalizedFormats;
+026import org.apache.commons.math3.util.FastMath;
+027import org.apache.commons.math3.util.MathArrays;
+028import org.apache.commons.math3.util.Precision;
+029
+030/**
+031 * Computes a cubic spline interpolation for the data set using the Akima
+032 * algorithm, as originally formulated by Hiroshi Akima in his 1970 paper
+033 * "A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures."
+034 * J. ACM 17, 4 (October 1970), 589-602. DOI=10.1145/321607.321609
+035 * http://doi.acm.org/10.1145/321607.321609
+036 * <p>
+037 * This implementation is based on the Akima implementation in the CubicSpline
+038 * class in the Math.NET Numerics library. The method referenced is
+039 * CubicSpline.InterpolateAkimaSorted
+040 * <p>
+041 * The {@link #interpolate(double[], double[])} method returns a
+042 * {@link PolynomialSplineFunction} consisting of n cubic polynomials, defined
+043 * over the subintervals determined by the x values, x[0] < x[i] ... < x[n]. The
+044 * Akima algorithm requires that n >= 5.
+045 * </p>
+046 * <p>
+047 */
+048
+049public class AkimaSplineInterpolator
+050    implements UnivariateInterpolator {
+051
+052
+053    /**
+054     * The minimum number of points that are needed to compute the function
+055     */
+056    public static final int MINIMUM_NUMBER_POINTS = 5;
+057
+058    /**
+059     * Default constructor. Builds an AkimaSplineInterpolator object
+060     */
+061    public AkimaSplineInterpolator() {
+062
+063    }
+064
+065    /**
+066     * Computes an interpolating function for the data set.
+067     *
+068     * @param xvals the arguments for the interpolation points
+069     * @param yvals the values for the interpolation points
+070     * @return a function which interpolates the data set
+071     * @throws DimensionMismatchException if {@code x} and {@code y} have
+072     *         different sizes.
+073     * @throws NonMonotonicSequenceException if {@code x} is not sorted in
+074     *         strict increasing order.
+075     * @throws NumberIsTooSmallException if the size of {@code x} is smaller
+076     *         than 5.
+077     */
+078    public PolynomialSplineFunction interpolate(double[] xvals, double[] yvals)
+079        throws DimensionMismatchException, NumberIsTooSmallException,
+080        NonMonotonicSequenceException {
+081        if (xvals == null || yvals == null) {
+082            throw new NullArgumentException();
+083        }
+084
+085        if (xvals.length != yvals.length) {
+086            throw new DimensionMismatchException(xvals.length, yvals.length);
+087        }
+088
+089        if (xvals.length < MINIMUM_NUMBER_POINTS) {
+090            throw new NumberIsTooSmallException(
+091                                                LocalizedFormats.NUMBER_OF_POINTS,
+092                                                xvals.length,
+093                                                MINIMUM_NUMBER_POINTS, true);
+094        }
+095
+096        MathArrays.checkOrder(xvals);
+097
+098        final int numberOfDiffAndWeightElements = xvals.length - 1;
+099
+100        double differences[] = new double[numberOfDiffAndWeightElements];
+101        double weights[] = new double[numberOfDiffAndWeightElements];
+102
+103        for (int i = 0; i < differences.length; i++) {
+104            differences[i] = (yvals[i + 1] - yvals[i]) /
+105                             (xvals[i + 1] - xvals[i]);
+106        }
+107
+108        for (int i = 1; i < weights.length; i++) {
+109            weights[i] = FastMath.abs(differences[i] - differences[i - 1]);
+110        }
+111
+112        /* Prepare Hermite interpolation scheme */
+113
+114        double firstDerivatives[] = new double[xvals.length];
+115
+116        for (int i = 2; i < firstDerivatives.length - 2; i++) {
+117            if (Precision.equals(weights[i - 1], 0.0) &&
+118                Precision.equals(weights[i + 1], 0.0)) {
+119                firstDerivatives[i] = (((xvals[i + 1] - xvals[i]) * differences[i - 1]) + ((xvals[i] - xvals[i - 1]) * differences[i])) /
+120                                      (xvals[i + 1] - xvals[i - 1]);
+121            } else {
+122                firstDerivatives[i] = ((weights[i + 1] * differences[i - 1]) + (weights[i - 1] * differences[i])) /
+123                                      (weights[i + 1] + weights[i - 1]);
+124            }
+125        }
+126
+127        firstDerivatives[0] = this.differentiateThreePoint(xvals, yvals, 0, 0,
+128                                                           1, 2);
+129        firstDerivatives[1] = this.differentiateThreePoint(xvals, yvals, 1, 0,
+130                                                           1, 2);
+131        firstDerivatives[xvals.length - 2] = this
+132            .differentiateThreePoint(xvals, yvals, xvals.length - 2,
+133                                     xvals.length - 3, xvals.length - 2,
+134                                     xvals.length - 1);
+135        firstDerivatives[xvals.length - 1] = this
+136            .differentiateThreePoint(xvals, yvals, xvals.length - 1,
+137                                     xvals.length - 3, xvals.length - 2,
+138                                     xvals.length - 1);
+139
+140        return this.interpolateHermiteSorted(xvals, yvals, firstDerivatives);
+141    }
+142
+143    /**
+144     * Three point differentiation helper, modeled off of the same method in the
+145     * Math.NET CubicSpline class. This is used by both the Apache Math and the
+146     * Math.NET Akima Cubic Spline algorithms
+147     *
+148     * @param xvals x values to calculate the numerical derivative with
+149     * @param yvals y values to calculate the numerical derivative with
+150     * @param indexOfDifferentiation index of the elemnt we are calculating the derivative around
+151     * @param indexOfFirstSample index of the first element to sample for the three point method
+152     * @param indexOfSecondsample index of the second element to sample for the three point method
+153     * @param indexOfThirdSample index of the third element to sample for the three point method
+154     * @return the derivative
+155     */
+156    private double differentiateThreePoint(double[] xvals, double[] yvals,
+157                                           int indexOfDifferentiation,
+158                                           int indexOfFirstSample,
+159                                           int indexOfSecondsample,
+160                                           int indexOfThirdSample) {
+161        double x0 = yvals[indexOfFirstSample];
+162        double x1 = yvals[indexOfSecondsample];
+163        double x2 = yvals[indexOfThirdSample];
+164
+165        double t = xvals[indexOfDifferentiation] - xvals[indexOfFirstSample];
+166        double t1 = xvals[indexOfSecondsample] - xvals[indexOfFirstSample];
+167        double t2 = xvals[indexOfThirdSample] - xvals[indexOfFirstSample];
+168
+169        double a = (x2 - x0 - (t2 / t1 * (x1 - x0))) / (t2 * t2 - t1 * t2);
+170        double b = (x1 - x0 - a * t1 * t1) / t1;
+171        return (2 * a * t) + b;
+172    }
+173
+174    /**
+175     * Creates a Hermite cubic spline interpolation from the set of (x,y) value
+176     * pairs and their derivatives. This is modeled off of the
+177     * InterpolateHermiteSorted method in the Math.NET CubicSpline class.
+178     *
+179     * @param xvals x values for interpolation
+180     * @param yvals y values for interpolation
+181     * @param firstDerivatives first derivative values of the function
+182     * @return polynomial that fits the function
+183     */
+184    private PolynomialSplineFunction interpolateHermiteSorted(double[] xvals,
+185                                                              double[] yvals,
+186                                                              double[] firstDerivatives) {
+187        if (xvals.length != yvals.length) {
+188            throw new DimensionMismatchException(xvals.length, yvals.length);
+189        }
+190
+191        if (xvals.length != firstDerivatives.length) {
+192            throw new DimensionMismatchException(xvals.length,
+193                                                 firstDerivatives.length);
+194        }
+195
+196        final int minimumLength = 2;
+197        if (xvals.length < minimumLength) {
+198            throw new NumberIsTooSmallException(
+199                                                LocalizedFormats.NUMBER_OF_POINTS,
+200                                                xvals.length, minimumLength,
+201                                                true);
+202        }
+203
+204        int size = xvals.length - 1;
+205        final PolynomialFunction polynomials[] = new PolynomialFunction[size];
+206        final double coefficients[] = new double[4];
+207
+208        for (int i = 0; i < polynomials.length; i++) {
+209            double w = xvals[i + 1] - xvals[i];
+210            double w2 = w * w;
+211            coefficients[0] = yvals[i];
+212            coefficients[1] = firstDerivatives[i];
+213            coefficients[2] = (3 * (yvals[i + 1] - yvals[i]) / w - 2 *
+214                               firstDerivatives[i] - firstDerivatives[i + 1]) /
+215                              w;
+216            coefficients[3] = (2 * (yvals[i] - yvals[i + 1]) / w +
+217                               firstDerivatives[i] + firstDerivatives[i + 1]) /
+218                              w2;
+219            polynomials[i] = new PolynomialFunction(coefficients);
+220        }
+221
+222        return new PolynomialSplineFunction(xvals, polynomials);
+223
+224    }
+225}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/analysis/interpolation/AkimaSplineInterpolator.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/analysis/interpolation/AkimaSplineInterpolator.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/ConstantRealDistribution.html ============================================================================== --- websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/ConstantRealDistribution.html (added) +++ websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/ConstantRealDistribution.html Sat Oct 18 20:10:38 2014 @@ -0,0 +1,193 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017
+018package org.apache.commons.math3.distribution;
+019
+020import org.apache.commons.math3.exception.OutOfRangeException;
+021
+022/**
+023 * Implementation of the constant real distribution.
+024 *
+025 * @since 3.4
+026 */
+027public class ConstantRealDistribution extends AbstractRealDistribution {
+028
+029    /** Serialization ID */
+030    private static final long serialVersionUID = -4157745166772046273L;
+031
+032    /** Constant value of the distribution */
+033    private final double value;
+034
+035    /**
+036     * Create a constant real distribution with the given value.
+037     *
+038     * @param value the constant value of this distribution
+039     */
+040    public ConstantRealDistribution(double value) {
+041        super(null);  // Avoid creating RandomGenerator
+042        this.value = value;
+043    }
+044
+045    /** {@inheritDoc} */
+046    public double density(double x) {
+047        return x == value ? 1 : 0;
+048    }
+049
+050    /** {@inheritDoc} */
+051    public double cumulativeProbability(double x)  {
+052        return x < value ? 0 : 1;
+053    }
+054
+055    @Override
+056    public double inverseCumulativeProbability(final double p)
+057            throws OutOfRangeException {
+058        if (p < 0.0 || p > 1.0) {
+059            throw new OutOfRangeException(p, 0, 1);
+060        }
+061        return value;
+062    }
+063
+064    /**
+065     * {@inheritDoc}
+066     */
+067    public double getNumericalMean() {
+068        return value;
+069    }
+070
+071    /**
+072     * {@inheritDoc}
+073     */
+074    public double getNumericalVariance() {
+075        return 0;
+076    }
+077
+078    /**
+079     * {@inheritDoc}
+080     */
+081    public double getSupportLowerBound() {
+082        return value;
+083    }
+084
+085    /**
+086     * {@inheritDoc}
+087     */
+088    public double getSupportUpperBound() {
+089        return value;
+090    }
+091
+092    /** {@inheritDoc} */
+093    public boolean isSupportLowerBoundInclusive() {
+094        return true;
+095    }
+096
+097    /** {@inheritDoc} */
+098    public boolean isSupportUpperBoundInclusive() {
+099        return true;
+100    }
+101
+102    /**
+103     * {@inheritDoc}
+104     */
+105    public boolean isSupportConnected() {
+106        return true;
+107    }
+108
+109    /** {@inheritDoc} */
+110    @Override
+111    public double sample()  {
+112        return value;
+113    }
+114
+115    /**
+116     * Override with no-op (there is no generator).
+117     * @param seed (ignored)
+118     */
+119    @Override
+120    public void reseedRandomGenerator(long seed) {}
+121}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/ConstantRealDistribution.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/ConstantRealDistribution.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/GumbelDistribution.html ============================================================================== --- websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/GumbelDistribution.html (added) +++ websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/GumbelDistribution.html Sat Oct 18 20:10:38 2014 @@ -0,0 +1,231 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017package org.apache.commons.math3.distribution;
+018
+019import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+020import org.apache.commons.math3.exception.OutOfRangeException;
+021import org.apache.commons.math3.exception.util.LocalizedFormats;
+022import org.apache.commons.math3.random.RandomGenerator;
+023import org.apache.commons.math3.random.Well19937c;
+024import org.apache.commons.math3.util.FastMath;
+025import org.apache.commons.math3.util.MathUtils;
+026
+027/**
+028 * This class implements the Gumbel distribution.
+029 *
+030 * @see <a href="http://en.wikipedia.org/wiki/Gumbel_distribution">Gumbel Distribution (Wikipedia)</a>
+031 * @see <a href="http://mathworld.wolfram.com/GumbelDistribution.html">Gumbel Distribution (Mathworld)</a>
+032 *
+033 * @since 3.4
+034 */
+035public class GumbelDistribution extends AbstractRealDistribution {
+036
+037    /** Serializable version identifier. */
+038    private static final long serialVersionUID = 20141003;
+039
+040    /**
+041     * Approximation of Euler's constant
+042     * see http://mathworld.wolfram.com/Euler-MascheroniConstantApproximations.html
+043     */
+044    private static final double EULER = FastMath.PI / (2 * FastMath.E);
+045
+046    /** The location parameter. */
+047    private final double mu;
+048    /** The scale parameter. */
+049    private final double beta;
+050
+051    /**
+052     * Build a new instance.
+053     *
+054     * @param mu location parameter
+055     * @param beta scale parameter (must be positive)
+056     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+057     */
+058    public GumbelDistribution(double mu, double beta) {
+059        this(new Well19937c(), mu, beta);
+060    }
+061
+062    /**
+063     * Build a new instance.
+064     *
+065     * @param rng Random number generator
+066     * @param mu location parameter
+067     * @param beta scale parameter (must be positive)
+068     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+069     */
+070    public GumbelDistribution(RandomGenerator rng, double mu, double beta) {
+071        super(rng);
+072
+073        if (beta <= 0) {
+074            throw new NotStrictlyPositiveException(LocalizedFormats.SCALE, beta);
+075        }
+076
+077        this.beta = beta;
+078        this.mu = mu;
+079    }
+080
+081    /**
+082     * Access the location parameter, {@code mu}.
+083     *
+084     * @return the location parameter.
+085     */
+086    public double getLocation() {
+087        return mu;
+088    }
+089
+090    /**
+091     * Access the scale parameter, {@code beta}.
+092     *
+093     * @return the scale parameter.
+094     */
+095    public double getScale() {
+096        return beta;
+097    }
+098
+099    /** {@inheritDoc} */
+100    public double density(double x) {
+101        final double z = (x - mu) / beta;
+102        final double t = FastMath.exp(-z);
+103        return FastMath.exp(-z - t) / beta;
+104    }
+105
+106    /** {@inheritDoc} */
+107    public double cumulativeProbability(double x) {
+108        final double z = (x - mu) / beta;
+109        return FastMath.exp(-FastMath.exp(-z));
+110    }
+111
+112    @Override
+113    public double inverseCumulativeProbability(double p) throws OutOfRangeException {
+114        if (p < 0.0 || p > 1.0) {
+115            throw new OutOfRangeException(p, 0.0, 1.0);
+116        } else if (p == 0) {
+117            return Double.NEGATIVE_INFINITY;
+118        } else if (p == 1) {
+119            return Double.POSITIVE_INFINITY;
+120        }
+121        return mu - FastMath.log(-FastMath.log(p)) * beta;
+122    }
+123
+124    /** {@inheritDoc} */
+125    public double getNumericalMean() {
+126        return mu + EULER * beta;
+127    }
+128
+129    /** {@inheritDoc} */
+130    public double getNumericalVariance() {
+131        return (MathUtils.PI_SQUARED) / 6.0 * (beta * beta);
+132    }
+133
+134    /** {@inheritDoc} */
+135    public double getSupportLowerBound() {
+136        return Double.NEGATIVE_INFINITY;
+137    }
+138
+139    /** {@inheritDoc} */
+140    public double getSupportUpperBound() {
+141        return Double.POSITIVE_INFINITY;
+142    }
+143
+144    /** {@inheritDoc} */
+145    public boolean isSupportLowerBoundInclusive() {
+146        return false;
+147    }
+148
+149    /** {@inheritDoc} */
+150    public boolean isSupportUpperBoundInclusive() {
+151        return false;
+152    }
+153
+154    /** {@inheritDoc} */
+155    public boolean isSupportConnected() {
+156        return true;
+157    }
+158
+159}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/GumbelDistribution.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/GumbelDistribution.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LaplaceDistribution.html ============================================================================== --- websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LaplaceDistribution.html (added) +++ websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LaplaceDistribution.html Sat Oct 18 20:10:38 2014 @@ -0,0 +1,225 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017package org.apache.commons.math3.distribution;
+018
+019import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+020import org.apache.commons.math3.exception.OutOfRangeException;
+021import org.apache.commons.math3.exception.util.LocalizedFormats;
+022import org.apache.commons.math3.random.RandomGenerator;
+023import org.apache.commons.math3.random.Well19937c;
+024import org.apache.commons.math3.util.FastMath;
+025
+026/**
+027 * This class implements the Laplace distribution.
+028 *
+029 * @see <a href="http://en.wikipedia.org/wiki/Laplace_distribution">Laplace distribution (Wikipedia)</a>
+030 *
+031 * @since 3.4
+032 */
+033public class LaplaceDistribution extends AbstractRealDistribution {
+034
+035    /** Serializable version identifier. */
+036    private static final long serialVersionUID = 20141003;
+037
+038    /** The location parameter. */
+039    private final double mu;
+040    /** The scale parameter. */
+041    private final double beta;
+042
+043    /**
+044     * Build a new instance.
+045     *
+046     * @param mu location parameter
+047     * @param beta scale parameter (must be positive)
+048     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+049     */
+050    public LaplaceDistribution(double mu, double beta) {
+051        this(new Well19937c(), mu, beta);
+052    }
+053
+054    /**
+055     * Build a new instance.
+056     *
+057     * @param rng Random number generator
+058     * @param mu location parameter
+059     * @param beta scale parameter (must be positive)
+060     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+061     */
+062    public LaplaceDistribution(RandomGenerator rng, double mu, double beta) {
+063        super(rng);
+064
+065        if (beta <= 0.0) {
+066            throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, beta);
+067        }
+068
+069        this.mu = mu;
+070        this.beta = beta;
+071    }
+072
+073    /**
+074     * Access the location parameter, {@code mu}.
+075     *
+076     * @return the location parameter.
+077     */
+078    public double getLocation() {
+079        return mu;
+080    }
+081
+082    /**
+083     * Access the scale parameter, {@code beta}.
+084     *
+085     * @return the scale parameter.
+086     */
+087    public double getScale() {
+088        return beta;
+089    }
+090
+091    /** {@inheritDoc} */
+092    public double density(double x) {
+093        return FastMath.exp(-FastMath.abs(x - mu) / beta) / (2.0 * beta);
+094    }
+095
+096    /** {@inheritDoc} */
+097    public double cumulativeProbability(double x) {
+098        if (x <= mu) {
+099            return FastMath.exp((x - mu) / beta) / 2.0;
+100        } else {
+101            return 1.0 - FastMath.exp((mu - x) / beta) / 2.0;
+102        }
+103    }
+104
+105    @Override
+106    public double inverseCumulativeProbability(double p) throws OutOfRangeException {
+107        if (p < 0.0 || p > 1.0) {
+108            throw new OutOfRangeException(p, 0.0, 1.0);
+109        } else if (p == 0) {
+110            return 0.0;
+111        } else if (p == 1) {
+112            return Double.POSITIVE_INFINITY;
+113        }
+114        double x = (p > 0.5) ? -Math.log(2.0 - 2.0 * p) : Math.log(2.0 * p);
+115        return mu + beta * x;
+116    }
+117
+118    /** {@inheritDoc} */
+119    public double getNumericalMean() {
+120        return mu;
+121    }
+122
+123    /** {@inheritDoc} */
+124    public double getNumericalVariance() {
+125        return 2.0 * beta * beta;
+126    }
+127
+128    /** {@inheritDoc} */
+129    public double getSupportLowerBound() {
+130        return Double.NEGATIVE_INFINITY;
+131    }
+132
+133    /** {@inheritDoc} */
+134    public double getSupportUpperBound() {
+135        return Double.POSITIVE_INFINITY;
+136    }
+137
+138    /** {@inheritDoc} */
+139    public boolean isSupportLowerBoundInclusive() {
+140        return false;
+141    }
+142
+143    /** {@inheritDoc} */
+144    public boolean isSupportUpperBoundInclusive() {
+145        return false;
+146    }
+147
+148    /** {@inheritDoc} */
+149    public boolean isSupportConnected() {
+150        return true;
+151    }
+152
+153}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LaplaceDistribution.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LaplaceDistribution.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LogisticDistribution.html ============================================================================== --- websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LogisticDistribution.html (added) +++ websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LogisticDistribution.html Sat Oct 18 20:10:38 2014 @@ -0,0 +1,225 @@ + + + +Source code + + + +
+
001/*
+002 * Licensed to the Apache Software Foundation (ASF) under one or more
+003 * contributor license agreements.  See the NOTICE file distributed with
+004 * this work for additional information regarding copyright ownership.
+005 * The ASF licenses this file to You under the Apache License, Version 2.0
+006 * (the "License"); you may not use this file except in compliance with
+007 * the License.  You may obtain a copy of the License at
+008 *
+009 *      http://www.apache.org/licenses/LICENSE-2.0
+010 *
+011 * Unless required by applicable law or agreed to in writing, software
+012 * distributed under the License is distributed on an "AS IS" BASIS,
+013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+014 * See the License for the specific language governing permissions and
+015 * limitations under the License.
+016 */
+017package org.apache.commons.math3.distribution;
+018
+019import org.apache.commons.math3.exception.NotStrictlyPositiveException;
+020import org.apache.commons.math3.exception.OutOfRangeException;
+021import org.apache.commons.math3.exception.util.LocalizedFormats;
+022import org.apache.commons.math3.random.RandomGenerator;
+023import org.apache.commons.math3.random.Well19937c;
+024import org.apache.commons.math3.util.FastMath;
+025import org.apache.commons.math3.util.MathUtils;
+026
+027/**
+028 * This class implements the Logistic distribution.
+029 *
+030 * @see <a href="http://en.wikipedia.org/wiki/Logistic_distribution">Logistic Distribution (Wikipedia)</a>
+031 * @see <a href="http://mathworld.wolfram.com/LogisticDistribution.html">Logistic Distribution (Mathworld)</a>
+032 *
+033 * @since 3.4
+034 */
+035public class LogisticDistribution extends AbstractRealDistribution {
+036
+037    /** Serializable version identifier. */
+038    private static final long serialVersionUID = 20141003;
+039
+040    /** The location parameter. */
+041    private final double mu;
+042    /** The scale parameter. */
+043    private final double s;
+044
+045    /**
+046     * Build a new instance.
+047     *
+048     * @param mu location parameter
+049     * @param s scale parameter (must be positive)
+050     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+051     */
+052    public LogisticDistribution(double mu, double s) {
+053        this(new Well19937c(), mu, s);
+054    }
+055
+056    /**
+057     * Build a new instance.
+058     *
+059     * @param rng Random number generator
+060     * @param mu location parameter
+061     * @param s scale parameter (must be positive)
+062     * @throws NotStrictlyPositiveException if {@code beta <= 0}
+063     */
+064    public LogisticDistribution(RandomGenerator rng, double mu, double s) {
+065        super(rng);
+066
+067        if (s <= 0.0) {
+068            throw new NotStrictlyPositiveException(LocalizedFormats.NOT_POSITIVE_SCALE, s);
+069        }
+070
+071        this.mu = mu;
+072        this.s = s;
+073    }
+074
+075    /**
+076     * Access the location parameter, {@code mu}.
+077     *
+078     * @return the location parameter.
+079     */
+080    public double getLocation() {
+081        return mu;
+082    }
+083
+084    /**
+085     * Access the scale parameter, {@code s}.
+086     *
+087     * @return the scale parameter.
+088     */
+089    public double getScale() {
+090        return s;
+091    }
+092
+093    /** {@inheritDoc} */
+094    public double density(double x) {
+095        double z = (x - mu) / s;
+096        double v = FastMath.exp(-z);
+097        return 1 / s * v / ((1.0 + v) * (1.0 + v));
+098    }
+099
+100    /** {@inheritDoc} */
+101    public double cumulativeProbability(double x) {
+102        double z = 1 / s * (x - mu);
+103        return 1.0 / (1.0 + FastMath.exp(-z));
+104    }
+105
+106    @Override
+107    public double inverseCumulativeProbability(double p) throws OutOfRangeException {
+108        if (p < 0.0 || p > 1.0) {
+109            throw new OutOfRangeException(p, 0.0, 1.0);
+110        } else if (p == 0) {
+111            return 0.0;
+112        } else if (p == 1) {
+113            return Double.POSITIVE_INFINITY;
+114        }
+115        return s * Math.log(p / (1.0 - p)) + mu;
+116    }
+117
+118    /** {@inheritDoc} */
+119    public double getNumericalMean() {
+120        return mu;
+121    }
+122
+123    /** {@inheritDoc} */
+124    public double getNumericalVariance() {
+125        return (MathUtils.PI_SQUARED / 3.0) * (1.0 / (s * s));
+126    }
+127
+128    /** {@inheritDoc} */
+129    public double getSupportLowerBound() {
+130        return Double.NEGATIVE_INFINITY;
+131    }
+132
+133    /** {@inheritDoc} */
+134    public double getSupportUpperBound() {
+135        return Double.POSITIVE_INFINITY;
+136    }
+137
+138    /** {@inheritDoc} */
+139    public boolean isSupportLowerBoundInclusive() {
+140        return false;
+141    }
+142
+143    /** {@inheritDoc} */
+144    public boolean isSupportUpperBoundInclusive() {
+145        return false;
+146    }
+147
+148    /** {@inheritDoc} */
+149    public boolean isSupportConnected() {
+150        return true;
+151    }
+152
+153}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LogisticDistribution.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: websites/production/commons/content/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/LogisticDistribution.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision