public double expectedShortfall(final double centile){
  QL.require(centile >= 0.9 && centile < 1.0,"percentile out of range [0.9, 1.0)");
  QL.ensure(samples() != 0,EMPTY_SAMPLE_SET);
  final double target=-valueAtRisk(centile);
  final Ops.DoublePredicate less=new Bind2ndPredicate(new LessThanPredicate(),target);
  final Pair<Double,Integer> result=expectationValue(new Identity(),less);
  final double x=result.first();
  final Integer N=result.second();
  QL.ensure(N != 0,NO_DATA_BELOW_THE_TARGET);
  return -Math.min(x,0.0);
}

public double expectedShortfall ( final double centile ) { QL . require ( centile >= 0.9 && centile < 1.0 , "percentile out of range [0.9, 1.0)" ) ; QL . ensure ( samples ( ) != 0 , EMPTY_SAMPLE_SET ) ; final double target = - valueAtRisk ( centile ) ; final Ops . DoublePredicate less = new Bind2ndPredicate ( new LessThanPredicate ( ) , target ) ; final Pair < Double , Integer > result = expectationValue ( new Identity ( ) , less ) ; final double x = result . first ( ) ; final Integer N = result . second ( ) ; QL . ensure ( N != 0 , NO_DATA_BELOW_THE_TARGET ) ; return - Math . min ( x , 0.0 ) ; }
expected shortfall at a given percentile < p > returns the expected loss in case that the loss exceeded a var threshold , < p > \ mathrme } \ left [ x \ ; | \ ; x < \ mathrm { var } ( p ) \ right ] , } < p > that is the average of observations below the given percentile \ f $ p \ f $ . also know as conditional value - at - risk .
