final double m = statistics.mean();
final double std = statistics.standardDeviation();
final InverseCumulativeNormal gInverse = new InverseCumulativeNormal(m, std);
final double var = gInverse.op(1.0 - percentile);
final NormalDistribution g = new NormalDistribution(m, std);
final double result = m - std * std * g.op(var) / (1.0 - percentile);
// expectedShortfall must be a loss
// this means that it has to be MIN(result, 0.0)
// expectedShortfall must also be a positive quantity, so -MIN(*)
return -Math.min(result, 0.0);
}