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

    https://github.com/apache/spark/pull/7278#discussion_r35343649
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/stat/test/AndersonDarlingTest.scala 
---
    @@ -0,0 +1,289 @@
    +/*
    + * 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 scala.annotation.varargs
    +
    +import collection.immutable.ListMap
    +
    +import org.apache.commons.math3.distribution.{ExponentialDistribution, 
GumbelDistribution,
    +  LogisticDistribution, NormalDistribution, WeibullDistribution}
    +
    +import org.apache.spark.Logging
    +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 repeated values occur (the presence of ties can affect 
the validity of the test).
    + * The AD test provides an alternative to the KS 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
    + * {{{
    + * A^2 = -N - \frac{1}{N}\sum_{i = 0}^{N} (2i + 1)(\ln{\Phi{(x_i)}} + 
\ln{(1 - \Phi{(x_{N+1-i})})
    + * }}}
    + * where {{{\Phi}}} is the CDF of the given distribution and `N` is the 
sample size.
    + * For more information 
@see[[https://en.wikipedia.org/wiki/Anderson%E2%80%93Darling_test]]
    + */
    +private[stat] object AndersonDarlingTest extends Logging {
    +
    +  object NullHypothesis extends Enumeration {
    +    type NullHypothesis = Value
    +    val OneSample = Value("Sample follows theoretical distribution.")
    +  }
    +
    +  /**
    +   * AndersonDarlingTheoreticalDist 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 AndersonDarlingTheoreticalDist extends Serializable {
    +    val params: Seq[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
    --- End diff --
    
    I'd call this getCriticalValues for clarity


---
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