public static Histogram productHistogram(Histogram hist1,Histogram hist2){
  Set<String> prodFlds=new HashSet<String>(hist1.fields());
  prodFlds.addAll(hist2.fields());
  Histogram prodHist=new Histogram(prodFlds);
  double numRec1=hist1.recordsOutput();
  double numRec2=hist2.recordsOutput();
  if (Double.compare(numRec1,1.0) < 0 || Double.compare(numRec2,1.0) < 0)   return prodHist;
  for (  String fld : hist1.fields())   for (  Bucket bkt : hist1.buckets(fld))   prodHist.addBucket(fld,new Bucket(bkt.valueRange(),bkt.frequency() * numRec2,bkt.distinctValues(),bkt.valuePercentiles()));
  for (  String fld : hist2.fields())   for (  Bucket bkt : hist2.buckets(fld))   prodHist.addBucket(fld,new Bucket(bkt.valueRange(),bkt.frequency() * numRec1,bkt.distinctValues(),bkt.valuePercentiles()));
  return prodHist;
}

public static Histogram productHistogram ( Histogram hist1 , Histogram hist2 ) { Set < String > prodFlds = new HashSet < String > ( hist1 . fields ( ) ) ; prodFlds . addAll ( hist2 . fields ( ) ) ; Histogram prodHist = new Histogram ( prodFlds ) ; double numRec1 = hist1 . recordsOutput ( ) ; double numRec2 = hist2 . recordsOutput ( ) ; if ( Double . compare ( numRec1 , 1.0 ) < 0 || Double . compare ( numRec2 , 1.0 ) < 0 ) return prodHist ; for ( String fld : hist1 . fields ( ) ) for ( Bucket bkt : hist1 . buckets ( fld ) ) prodHist . addBucket ( fld , new Bucket ( bkt . valueRange ( ) , bkt . frequency ( ) * numRec2 , bkt . distinctValues ( ) , bkt . valuePercentiles ( ) ) ) ; for ( String fld : hist2 . fields ( ) ) for ( Bucket bkt : hist2 . buckets ( fld ) ) prodHist . addBucket ( fld , new Bucket ( bkt . valueRange ( ) , bkt . frequency ( ) * numRec1 , bkt . distinctValues ( ) , bkt . valuePercentiles ( ) ) ) ; return prodHist ; }
returns a histogram that , for each field , approximates the value distribution of products from the specified histograms .
