public static Object statTdist(Object[] args, XelContext ctx) throws MathException{
//EXCEL: TDIST(x,degrees_freedom,tails)
double x = CommonFns.toNumber(args[0]).doubleValue();
double degree_freedom = CommonFns.toNumber(args[1]).doubleValue();
int tails = CommonFns.toNumber(args[2]).intValue();
DistributionFactory factory = DistributionFactory.newInstance();
TDistribution td = factory.createTDistribution(degree_freedom );
return UtilFns.validateNumber(1 - td.cumulativeProbability(x));
}