@@ -31,12 +31,6 @@ public class ChangePointAggregator extends SiblingPipelineAggregator {
3131 static final double P_VALUE_THRESHOLD = 0.01 ;
3232 static final int MINIMUM_BUCKETS = 10 ;
3333
34- private static double changePValueThreshold (int nValues ) {
35- // This was obtained by simulating the test power for a fixed size effect as a
36- // function of the bucket value count.
37- return P_VALUE_THRESHOLD * Math .exp (-0.04 * (double ) (nValues - 2 * (MINIMUM_BUCKETS + 1 )));
38- }
39-
4034 public ChangePointAggregator (String name , String bucketsPath , Map <String , Object > metadata ) {
4135 super (name , new String [] { bucketsPath }, metadata );
4236 }
@@ -82,24 +76,22 @@ static ChangeType getChangeType(MlAggsHelper.DoubleBucketValues bucketValues) {
8276 );
8377 }
8478
85- ChangeType spikeOrDip = testForSpikeOrDip (bucketValues , P_VALUE_THRESHOLD );
86- ChangeType change = new ChangeDetector (bucketValues ).detect (changePValueThreshold (bucketValues .getValues ().length ));
87- logger .trace ("change p-value: [{}]" , change .pValue ());
88- if (spikeOrDip .pValue () < change .pValue ()) {
89- change = spikeOrDip ;
90- }
91- return change ;
92- }
93-
94- static ChangeType testForSpikeOrDip (MlAggsHelper .DoubleBucketValues bucketValues , double pValueThreshold ) {
79+ ChangeType spikeOrDip ;
9580 try {
9681 SpikeAndDipDetector detect = new SpikeAndDipDetector (bucketValues );
97- ChangeType result = detect .detect (pValueThreshold );
98- logger .trace ("spike or dip p-value: [{}]" , result .pValue ());
99- return result ;
82+ spikeOrDip = detect .detect (P_VALUE_THRESHOLD );
83+ logger .trace ("spike or dip p-value: [{}]" , spikeOrDip .pValue ());
10084 } catch (NotStrictlyPositiveException nspe ) {
10185 logger .debug ("failure testing for dips and spikes" , nspe );
102- return new Indeterminable ("failure testing for dips and spikes" );
86+ spikeOrDip = new Indeterminable ("failure testing for dips and spikes" );
87+ }
88+
89+ ChangeType change = new ChangeDetector (bucketValues ).detect (P_VALUE_THRESHOLD );
90+ logger .trace ("change p-value: [{}]" , change .pValue ());
91+
92+ if (spikeOrDip .pValue () < change .pValue ()) {
93+ change = spikeOrDip ;
10394 }
95+ return change ;
10496 }
10597}
0 commit comments