public class BETADIST extends AbstractFunction
{
public Expr evaluate(Expr[] args) throws ExprException {
assertMinArgCount(args, 3);
assertMaxArgCount(args, 5);
Expr eX = evalArg(args[0]);
if (!isNumber(eX))
return ExprError.VALUE;
double x = ((ExprNumber) eX).doubleValue();
Expr eAlpha = evalArg(args[1]);
if (!isNumber(eAlpha))
return ExprError.VALUE;
double alpha = ((ExprNumber) eAlpha).doubleValue();
if (alpha <= 0)
return ExprError.NUM;
Expr eBeta = evalArg(args[2]);
if (!isNumber(eBeta))
return ExprError.VALUE;
double beta = ((ExprNumber) eBeta).doubleValue();
if (beta <= 0)
return ExprError.NUM;
double a = 0, b = 1;
if (args.length > 3) {
Expr eA = evalArg(args[3]);
if (!isNumber(eA))
return ExprError.VALUE;
a = ((ExprNumber) eA).doubleValue();
}
if (args.length > 4) {
Expr eB = evalArg(args[4]);
if (!isNumber(eB))
return ExprError.VALUE;
b = ((ExprNumber) eB).doubleValue();
}
if (x < a || x > b || a == b)