Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/11356#discussion_r54047942
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala ---
@@ -71,6 +71,41 @@ final class DataFrameStatFunctions private[sql](df:
DataFrame) {
}
/**
+ * Calculates the approximate quantiles of a numerical column of a
DataFrame.
+ * Provided for the Python API.
+ *
+ * The result of this algorithm has the following deterministic bound:
+ * If the DataFrame has N elements and if we request the quantile at
probability `p` up to error
+ * `err`, then the algorithm will return a sample `x` from the DataFrame
so that the *exact* rank
+ * of `x` is close to (p * N).
+ * More precisely,
+ *
+ * floor((p - err) * N) <= rank(x) <= ceil((p + err) * N).
+ *
+ * This method implements a variation of the Greenwald-Khanna algorithm
(with some speed
+ * optimizations).
+ * The algorithm was first present in
[[http://dx.doi.org/10.1145/375663.375670 Space-efficient
+ * Online Computation of Quantile Summaries]] by Greenwald and Khanna.
+ *
+ * @param col the name of the numerical column
+ * @param probabilities a list of quantile probabilities
+ * Each number must belong to [0, 1].
+ * For example 0 is the minimum, 0.5 is the median, 1 is the maximum.
+ * @param relativeError The relative target precision to achieve (>= 0).
+ * If set to zero, the exact quantiles are computed, which could be
very expensive.
+ * Note that values greater than 1 are accepted but give the same
result as 1.
+ * @return the approximate quantiles at the given probabilities
+ *
+ * @since 2.0.0
+ */
+ private[spark] def approxQuantile(
+ col: String,
+ probabilities: List[Double],
+ relativeError: Double): Array[Double] = {
--- End diff --
Yeah, again I was trying to follow other code there...but probably
shouldn't. Fixed now.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]