-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(judge): Implement effect size post-MannWhitney check (#356)
- Loading branch information
1 parent
f8f6a3d
commit 3f7ed70
Showing
10 changed files
with
353 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
kayenta-judge/src/main/scala/com/netflix/kayenta/judge/stats/EffectSizes.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.netflix.kayenta.judge.stats | ||
|
||
import com.netflix.kayenta.judge.Metric | ||
import com.netflix.kayenta.judge.stats.DescriptiveStatistics._ | ||
import org.apache.commons.math.util.FastMath | ||
import org.apache.commons.math3.stat.StatUtils | ||
|
||
|
||
object EffectSizes { | ||
|
||
/** | ||
* Mean Ratio | ||
* Measures the difference between the mean values as a ratio (experiment/control) | ||
* Note: This is included for backwards compatibility | ||
*/ | ||
def meanRatio(control: Array[Double], experiment: Array[Double]): Double = { | ||
require(StatUtils.mean(control) != 0.0, "the mean of the control must be non-zero") | ||
StatUtils.mean(experiment)/StatUtils.mean(control) | ||
} | ||
|
||
/** | ||
* Mean Ratio | ||
* Measures the difference between the mean values as a ratio (experiment/control) | ||
* Note: This is included for backwards compatibility | ||
*/ | ||
def meanRatio(control: Metric, experiment: Metric): Double = { | ||
require(mean(control) != 0.0, "the mean of the control must be non-zero") | ||
mean(experiment)/mean(control) | ||
} | ||
|
||
/** | ||
* Mean Ratio | ||
* Measures the difference between the mean values as a ratio (experiment/control) | ||
* Note: This is included for backwards compatibility | ||
*/ | ||
def meanRatio(control: MetricStatistics, experiment: MetricStatistics): Double = { | ||
require(control.mean != 0.0, "the mean of the control must be non-zero") | ||
experiment.mean/control.mean | ||
} | ||
|
||
/** | ||
* Cohen's d (Pooled Standard Deviation) | ||
* Cohen's d is an effect size used to indicate the standardized difference between two means | ||
* https://en.wikipedia.org/wiki/Effect_size#Cohen's_d | ||
*/ | ||
def cohenD(control: Metric, experiment: Metric): Double = { | ||
cohenD(summary(control), summary(experiment)) | ||
} | ||
|
||
/** | ||
* Cohen's d (Pooled Standard Deviation) | ||
* Cohen's d is an effect size used to indicate the standardized difference between two means | ||
* https://en.wikipedia.org/wiki/Effect_size#Cohen's_d | ||
*/ | ||
def cohenD(control: MetricStatistics, experiment: MetricStatistics): Double = { | ||
val pooledStd = FastMath.sqrt(((experiment.count - 1) * FastMath.pow(experiment.std, 2) + (control.count - 1) * FastMath.pow(control.std, 2)) / (control.count + experiment.count - 2)) | ||
FastMath.abs(experiment.mean - control.mean) / pooledStd | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.