/** * {@inheritDoc} */ @Override public ThirdMoment copy() { ThirdMoment result = new ThirdMoment(); // No try-catch or advertised exception because args are guaranteed non-null copy(this, result); return result; }
/** * {@inheritDoc} */ @Override public void clear() { if (incMoment) { moment.clear(); } }
/** * {@inheritDoc} */ public long getN() { return moment.getN(); }
/** * Copy constructor, creates a new {@code ThirdMoment} identical * to the {@code original} * * @param original the {@code ThirdMoment} instance to copy * @throws NullArgumentException if orginal is null */ ThirdMoment(ThirdMoment original) throws NullArgumentException { copy(original, this); }
/** * {@inheritDoc} * <p>Note that when {@link #Skewness(ThirdMoment)} is used to * create a Skewness, this method does nothing. In that case, the * ThirdMoment should be incremented directly.</p> */ @Override public void increment(final double d) { if (incMoment) { moment.increment(d); } }
/** * Constructs a Skewness */ public Skewness() { incMoment = true; moment = new ThirdMoment(); }
/** * Copies source to dest. * <p>Neither source nor dest can be null.</p> * * @param source FourthMoment to copy * @param dest FourthMoment to copy to * @throws NullArgumentException if either source or dest is null */ public static void copy(FourthMoment source, FourthMoment dest) throws NullArgumentException { MathUtils.checkNotNull(source); MathUtils.checkNotNull(dest); ThirdMoment.copy(source, dest); dest.m4 = source.m4; } }
/** * {@inheritDoc} */ @Override public void increment(final double d) { if (n < 1) { m4 = 0.0; m3 = 0.0; m2 = 0.0; m1 = 0.0; } double prevM3 = m3; double prevM2 = m2; super.increment(d); double n0 = n; m4 = m4 - 4.0 * nDev * prevM3 + 6.0 * nDevSq * prevM2 + ((n0 * n0) - 3 * (n0 -1)) * (nDevSq * nDevSq * (n0 - 1) * n0); }
/** * Constructs a Skewness */ public Skewness() { incMoment = true; moment = new ThirdMoment(); }
/** * Copies source to dest. * <p>Neither source nor dest can be null.</p> * * @param source Skewness to copy * @param dest Skewness to copy to * @throws NullArgumentException if either source or dest is null */ public static void copy(Skewness source, Skewness dest) throws NullArgumentException { MathUtils.checkNotNull(source); MathUtils.checkNotNull(dest); dest.setData(source.getDataRef()); dest.moment = new ThirdMoment(source.moment.copy()); dest.incMoment = source.incMoment; } }
/** * Returns the value of the statistic based on the values that have been added. * <p> * See {@link Skewness} for the definition used in the computation.</p> * * @return the skewness of the available values. */ @Override public double getResult() { if (moment.n < 3) { return Double.NaN; } double variance = moment.m2 / (moment.n - 1); if (variance < 10E-20) { return 0.0d; } else { double n0 = moment.getN(); return (n0 * moment.m3) / ((n0 - 1) * (n0 -2) * FastMath.sqrt(variance) * variance); } }
/** * Copy constructor, creates a new {@code ThirdMoment} identical * to the {@code original} * * @param original the {@code ThirdMoment} instance to copy * @throws NullArgumentException if orginal is null */ ThirdMoment(ThirdMoment original) throws NullArgumentException { copy(original, this); }
/** * {@inheritDoc} */ @Override public void clear() { super.clear(); m4 = Double.NaN; }
/** * {@inheritDoc} * <p>Note that when {@link #Skewness(ThirdMoment)} is used to * create a Skewness, this method does nothing. In that case, the * ThirdMoment should be incremented directly.</p> */ @Override public void increment(final double d) { if (incMoment) { moment.increment(d); } }
/** * Constructs a Skewness */ public Skewness() { incMoment = true; moment = new ThirdMoment(); }
/** * {@inheritDoc} */ @Override public ThirdMoment copy() { ThirdMoment result = new ThirdMoment(); // No try-catch or advertised exception because args are guaranteed non-null copy(this, result); return result; }
/** * {@inheritDoc} */ public long getN() { return moment.getN(); }
/** * Copy constructor, creates a new {@code ThirdMoment} identical * to the {@code original} * * @param original the {@code ThirdMoment} instance to copy * @throws NullArgumentException if orginal is null */ ThirdMoment(ThirdMoment original) throws NullArgumentException { copy(original, this); }
/** * {@inheritDoc} */ @Override public void clear() { if (incMoment) { moment.clear(); } }
/** * {@inheritDoc} * <p>Note that when {@link #Skewness(ThirdMoment)} is used to * create a Skewness, this method does nothing. In that case, the * ThirdMoment should be incremented directly.</p> */ @Override public void increment(final double d) { if (incMoment) { moment.increment(d); } }