public static Bucket joinFieldBucket ( Bucket bkt1 , Bucket bkt2 , double numRec ) { ConstantRange newRange = bkt1 . valueRange ( ) . intersect ( bkt2 . valueRange ( ) ) ; if ( ! newRange . isValid ( ) ) return null ; double rdv1 = bkt1 . distinctValues ( newRange ) ; double rdv2 = bkt2 . distinctValues ( newRange ) ; double newDistVals = Math . min ( rdv1 , rdv2 ) ; if ( Double . compare ( newDistVals , 1.0 ) < 0 ) return null ; double newFreq = Math . min ( bkt1 . frequency ( ) * ( bkt2 . frequency ( ) / numRec ) * ( newDistVals / bkt1 . distinctValues ( ) ) / rdv2 , bkt2 . frequency ( ) * ( bkt1 . frequency ( ) / numRec ) * ( newDistVals / bkt2 . distinctValues ( ) ) / rdv1 ) ; if ( Double . compare ( newFreq , 1.0 ) < 0 ) return null ; Bucket smaller = rdv1 < rdv2 ? bkt1 : bkt2 ; if ( smaller . valuePercentiles ( ) == null ) return new Bucket ( newRange , newFreq , newDistVals ) ; Percentiles newPcts = smaller . valuePercentiles ( ) . percentiles ( newRange ) ; return new Bucket ( newRange , newFreq , newDistVals , newPcts ) ; }
Creates a new bucket by keeping the statistics of joining records and values from the two specified buckets .