Github user feynmanliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7278#discussion_r34304021
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/stat/test/ADTest.scala ---
    @@ -0,0 +1,264 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.mllib.stat.test
    +
    +import collection.immutable.ListMap
    +
    +import org.apache.commons.math3.distribution.{ExponentialDistribution, 
GumbelDistribution,
    +  LogisticDistribution, NormalDistribution, WeibullDistribution}
    +
    +import org.apache.spark.rdd.RDD
    +
    +/**
    + * The Anderson Darling (AD) test, similarly to the Kolmogorov Smirnov 
(KS) test, tests whether the
    + * data follow a given theoretical distribution. It should be used with 
continuous data and
    + * assumes that no ties occur (the presence of ties can affect the 
validity of the test).
    + * The AD test provides an alternative to the Kolmogorov-Smirnov test. 
Namely, it is better
    + * suited to identify departures from the theoretical distribution at the 
tails.
    + * It is worth noting that the the AD test's critical values depend on the
    + * distribution being tested against.
    + * The  AD statistic is defined as -n - s/n, where
    + * s = sum from i=1 to n of (2i + 1)(ln(z_i) + ln(1 - z_{n+1-i})
    + * where z_i is the CDF value of the ith observation in the sorted sample.
    + * For more information 
@see[[https://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test]]
    + */
    +private[stat] object ADTest {
    +
    +  object NullHypothesis extends Enumeration {
    +    type NullHypothesis = Value
    +    val oneSample = Value("Sample follows theoretical distribution.")
    +  }
    +
    +  /**
    +   * ADTheoreticalDist is a trait that every distribution used in an AD 
test must extend.
    +   * The rationale for this is that the AD test has distribution-dependent 
critical values, and by
    +   * requiring extension of this trait we guarantee that future additional 
distributions
    +   * make sure to add the appropriate critical values (CVs) (or at least 
acknowledge
    +   * that they should be added)
    +   */
    +  sealed trait ADTheoreticalDist {
    +    val params: Array[Double]  // parameters used to initialized the 
distribution
    +
    +    def cdf(x: Double): Double // calculate the cdf under the given 
distribution for value x
    +
    +    def getCVs(n: Double): Map[Double, Double] // return appropriate CVs, 
adjusted for sample size
    +  }
    +
    +  /**
    +   * Sourced from
    +   * 
http://civil.colorado.edu/~balajir/CVEN5454/lectures/Ang-n-Tang-Chap7-Goodness-of-fit-PDFs-
    --- End diff --
    
    Single line for easier copy+pasting, wrap in `[[...]]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to