/** change the parameter and return the hastings ratio. */
  public double doOperation() throws OperatorFailedException {

    double[] mean = sccs.getMode();
    double[] currentValue = parameter.getParameterValues();
    double[] newValue = new double[dim];

    Set<Integer> updateSet = new HashSet<Integer>();

    if (setSizeMean != -1.0) {
      final int listLength = Poisson.nextPoisson(setSizeMean);
      while (updateSet.size() < listLength) {
        int newInt = MathUtils.nextInt(parameter.getDimension());
        if (!updateSet.contains(newInt)) {
          updateSet.add(newInt);
        }
      }
    } else {
      for (int i = 0; i < dim; ++i) {
        updateSet.add(i);
      }
    }

    double logq = 0;
    for (Integer i : updateSet) {
      newValue[i] = mean[i] + scaleFactor * MathUtils.nextGaussian();
      if (UPDATE_ALL) {
        parameter.setParameterValueQuietly(i, newValue[i]);
      } else {
        parameter.setParameterValue(i, newValue[i]);
      }

      logq +=
          (NormalDistribution.logPdf(currentValue[i], mean[i], scaleFactor)
              - NormalDistribution.logPdf(newValue[i], mean[i], scaleFactor));
    }

    //        for (Integer i : updateSet) {
    //            parameter.setParameterValueQuietly(i, newValue[i]);
    //        }

    if (UPDATE_ALL) {
      parameter.setParameterValueNotifyChangedAll(0, parameter.getParameterValue(0));
    }

    return logq;
  }