public double doOperation() throws OperatorFailedException {
  final double priorMean=prior.mean();
  final double priorVariance=prior.variance();
  double priorRate;
  double priorShape;
  if (priorMean == 0) {
    priorRate=0;
    priorShape=-0.5;
  }
 else {
    priorRate=priorMean / priorVariance;
    priorShape=priorMean * priorRate;
  }
  final double mu=meanParameter.getParameterValue(0);
  double SSE=0;
  int n=0;
  for (  Attribute<double[]> statistic : dataList) {
    for (    double x : statistic.getAttributeValue()) {
      if (isLog) {
        final double logX=Math.log(x);
        SSE+=(logX - mu) * (logX - mu);
      }
 else {
        SSE+=(x - mu) * (x - mu);
      }
      n++;
    }
  }
  final double shape=priorShape + n / 2.0;
  final double rate=priorRate + 0.5 * SSE;
  final double draw=MathUtils.nextGamma(shape,rate);
  precisionParameter.setParameterValue(0,draw);
  return 0;
}

public double doOperation ( ) throws OperatorFailedException { final double priorMean = prior . mean ( ) ; final double priorVariance = prior . variance ( ) ; double priorRate ; double priorShape ; if ( priorMean == 0 ) { priorRate = 0 ; priorShape = - 0.5 ; } else { priorRate = priorMean / priorVariance ; priorShape = priorMean * priorRate ; } final double mu = meanParameter . getParameterValue ( 0 ) ; double SSE = 0 ; int n = 0 ; for ( Attribute < double [ ] > statistic : dataList ) { for ( double x : statistic . getAttributeValue ( ) ) { if ( isLog ) { final double logX = Math . log ( x ) ; SSE += ( logX - mu ) * ( logX - mu ) ; } else { SSE += ( x - mu ) * ( x - mu ) ; } n ++ ; } } final double shape = priorShape + n / 2.0 ; final double rate = priorRate + 0.5 * SSE ; final double draw = MathUtils . nextGamma ( shape , rate ) ; precisionParameter . setParameterValue ( 0 , draw ) ; return 0 ; }
called by operate ( ) , does the actual operation .
