⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 descriptivestatistics.java

📁 Apache的common math数学软件包
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        System.arraycopy(eDA.getElements(), 0, copiedArray,            0, eDA.getNumElements());        return copiedArray;    }    /**     * Returns the current set of values in an array of double primitives,       * sorted in ascending order.  The returned array is a fresh     * copy of the underlying data -- i.e., it is not a reference to the     * stored data.     * @return returns the current set of      * numbers sorted in ascending order             */    public double[] getSortedValues() {        double[] sort = getValues();        Arrays.sort(sort);        return sort;    }    /**     * Returns the element at the specified index     * @param index The Index of the element     * @return return the element at the specified index     */    public double getElement(int index) {        return eDA.getElement(index);    }    /**     * Returns an estimate for the pth percentile of the stored values.      * <p>     * The implementation provided here follows the first estimation procedure presented     * <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>     * </p><p>     * <strong>Preconditions</strong>:<ul>     * <li><code>0 &lt; p &lt; 100</code> (otherwise an      * <code>IllegalArgumentException</code> is thrown)</li>     * <li>at least one value must be stored (returns <code>Double.NaN     *     </code> otherwise)</li>     * </ul></p>     *      * @param p the requested percentile (scaled from 0 - 100)     * @return An estimate for the pth percentile of the stored data      * @throws IllegalStateException if percentile implementation has been     *  overridden and the supplied implementation does not support setQuantile     * values     */    public double getPercentile(double p) {        if (percentileImpl instanceof Percentile) {            ((Percentile) percentileImpl).setQuantile(p);        } else {            try {                percentileImpl.getClass().getMethod("setQuantile",                         new Class[] {Double.TYPE}).invoke(percentileImpl,                                new Object[] {new Double(p)});            } catch (NoSuchMethodException e1) { // Setter guard should prevent                throw new IllegalArgumentException(                   "Percentile implementation does not support setQuantile");            } catch (IllegalAccessException e2) {                throw new IllegalArgumentException(                    "IllegalAccessException setting quantile");             } catch (InvocationTargetException e3) {                throw new IllegalArgumentException(                    "Error setting quantile" + e3.toString());             }        }        return apply(percentileImpl);    }        /**     * Generates a text report displaying univariate statistics from values     * that have been added.  Each statistic is displayed on a separate     * line.     *      * @return String with line feeds displaying statistics     */    public String toString() {        StringBuffer outBuffer = new StringBuffer();        outBuffer.append("DescriptiveStatistics:\n");        outBuffer.append("n: " + getN() + "\n");        outBuffer.append("min: " + getMin() + "\n");        outBuffer.append("max: " + getMax() + "\n");        outBuffer.append("mean: " + getMean() + "\n");        outBuffer.append("std dev: " + getStandardDeviation() + "\n");        outBuffer.append("median: " + getPercentile(50) + "\n");        outBuffer.append("skewness: " + getSkewness() + "\n");        outBuffer.append("kurtosis: " + getKurtosis() + "\n");        return outBuffer.toString();    }        /**     * Apply the given statistic to the data associated with this set of statistics.     * @param stat the statistic to apply     * @return the computed value of the statistic.     */    public double apply(UnivariateStatistic stat) {        return stat.evaluate(eDA.getValues(), eDA.start(), eDA.getNumElements());    }    // Implementation getters and setter        /**     * Returns the currently configured mean implementation.     *      * @return the UnivariateStatistic implementing the mean     * @since 1.2     */    public synchronized UnivariateStatistic getMeanImpl() {        return meanImpl;    }    /**     * <p>Sets the implementation for the mean.</p>     *      * @param meanImpl the UnivariateStatistic instance to use     * for computing the mean     * @since 1.2     */    public synchronized void setMeanImpl(UnivariateStatistic meanImpl) {        this.meanImpl = meanImpl;    }    /**     * Returns the currently configured geometric mean implementation.     *      * @return the UnivariateStatistic implementing the geometric mean     * @since 1.2     */    public synchronized UnivariateStatistic getGeometricMeanImpl() {        return geometricMeanImpl;    }    /**     * <p>Sets the implementation for the gemoetric mean.</p>     *      * @param geometricMeanImpl the UnivariateStatistic instance to use     * for computing the geometric mean     * @since 1.2     */    public synchronized void setGeometricMeanImpl(            UnivariateStatistic geometricMeanImpl) {        this.geometricMeanImpl = geometricMeanImpl;    }    /**     * Returns the currently configured kurtosis implementation.     *      * @return the UnivariateStatistic implementing the kurtosis     * @since 1.2     */    public synchronized UnivariateStatistic getKurtosisImpl() {        return kurtosisImpl;    }    /**     * <p>Sets the implementation for the kurtosis.</p>     *      * @param kurtosisImpl the UnivariateStatistic instance to use     * for computing the kurtosis     * @since 1.2     */    public synchronized void setKurtosisImpl(UnivariateStatistic kurtosisImpl) {        this.kurtosisImpl = kurtosisImpl;    }    /**     * Returns the currently configured maximum implementation.     *      * @return the UnivariateStatistic implementing the maximum     * @since 1.2     */    public synchronized UnivariateStatistic getMaxImpl() {        return maxImpl;    }    /**     * <p>Sets the implementation for the maximum.</p>     *      * @param maxImpl the UnivariateStatistic instance to use     * for computing the maximum     * @since 1.2     */    public synchronized void setMaxImpl(UnivariateStatistic maxImpl) {        this.maxImpl = maxImpl;    }    /**     * Returns the currently configured minimum implementation.     *      * @return the UnivariateStatistic implementing the minimum     * @since 1.2     */    public synchronized UnivariateStatistic getMinImpl() {        return minImpl;    }    /**     * <p>Sets the implementation for the minimum.</p>     *      * @param minImpl the UnivariateStatistic instance to use     * for computing the minimum     * @since 1.2     */    public synchronized void setMinImpl(UnivariateStatistic minImpl) {        this.minImpl = minImpl;    }    /**     * Returns the currently configured percentile implementation.     *      * @return the UnivariateStatistic implementing the percentile     * @since 1.2     */    public synchronized UnivariateStatistic getPercentileImpl() {        return percentileImpl;    }    /**     * Sets the implementation to be used by {@link #getPercentile(double)}.     * The supplied <code>UnivariateStatistic</code> must provide a     * <code>setQuantile(double)</code> method; otherwise      * <code>IllegalArgumentException</code> is thrown.     *      * @param percentileImpl the percentileImpl to set     * @throws IllegalArgumentException if the supplied implementation does not     *  provide a <code>setQuantile</code> method     * @since 1.2     */    public synchronized void setPercentileImpl(            UnivariateStatistic percentileImpl) {        try {            percentileImpl.getClass().getMethod("setQuantile",                     new Class[] {Double.TYPE}).invoke(percentileImpl,                            new Object[] {new Double(50.0d)});        } catch (NoSuchMethodException e1) {             throw new IllegalArgumentException(                    "Percentile implementation does not support setQuantile");        } catch (IllegalAccessException e2) {            throw new IllegalArgumentException(                "IllegalAccessException setting quantile");         } catch (InvocationTargetException e3) {            throw new IllegalArgumentException(                "Error setting quantile" + e3.toString());         }        this.percentileImpl = percentileImpl;    }    /**     * Returns the currently configured skewness implementation.     *      * @return the UnivariateStatistic implementing the skewness     * @since 1.2     */    public synchronized UnivariateStatistic getSkewnessImpl() {        return skewnessImpl;    }    /**     * <p>Sets the implementation for the skewness.</p>     *      * @param skewnessImpl the UnivariateStatistic instance to use     * for computing the skewness     * @since 1.2     */    public synchronized void setSkewnessImpl(            UnivariateStatistic skewnessImpl) {        this.skewnessImpl = skewnessImpl;    }    /**     * Returns the currently configured variance implementation.     *      * @return the UnivariateStatistic implementing the variance     * @since 1.2     */    public synchronized UnivariateStatistic getVarianceImpl() {        return varianceImpl;    }    /**     * <p>Sets the implementation for the variance.</p>     *      * @param varianceImpl the UnivariateStatistic instance to use     * for computing the variance     * @since 1.2     */    public synchronized void setVarianceImpl(            UnivariateStatistic varianceImpl) {        this.varianceImpl = varianceImpl;    }    /**     * Returns the currently configured sum of squares implementation.     *      * @return the UnivariateStatistic implementing the sum of squares     * @since 1.2     */    public synchronized UnivariateStatistic getSumsqImpl() {        return sumsqImpl;    }    /**     * <p>Sets the implementation for the sum of squares.</p>     *      * @param sumsqImpl the UnivariateStatistic instance to use     * for computing the sum of squares     * @since 1.2     */    public synchronized void setSumsqImpl(UnivariateStatistic sumsqImpl) {        this.sumsqImpl = sumsqImpl;    }    /**     * Returns the currently configured sum implementation.     *      * @return the UnivariateStatistic implementing the sum     * @since 1.2     */    public synchronized UnivariateStatistic getSumImpl() {        return sumImpl;    }    /**     * <p>Sets the implementation for the sum.</p>     *      * @param sumImpl the UnivariateStatistic instance to use     * for computing the sum     * @since 1.2     */    public synchronized void setSumImpl(UnivariateStatistic sumImpl) {        this.sumImpl = sumImpl;    }   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -