private IExpr msub(NodeList list) { if (list.getLength() == 2) { Node arg1 = list.item(0); Node arg2 = list.item(1); IExpr a1 = toExpr(arg1); IExpr a2 = toExpr(arg2); if (a1.equals(F.Limit)) { // Limit(#,a2)& return F.Function(F.Limit(F.Slot1, a2)); } return F.binaryAST2(F.Subscript, a1, a2); } throw new AbortException(); }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkRange(ast, 2, 3); IExpr arg1 = ast.arg1(); int[] dim = arg1.isMatrix(); if (dim != null) { // Gram-Schmidt orthogonalization IExpr result = F.Map(F.Function(F.Normalize(F.Slot1)), // F.Fold(F.Function(F.Append(F.Slot1, F.binaryAST2(oneStep, F.Slot2, F.Slot1))), F.List(), arg1)); return engine.evaluate(result); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { IExpr[] minMax = minmax(dist); if (minMax != null) { IExpr a = minMax[0]; IExpr b = minMax[1]; IExpr function = // [$ ( Piecewise({{1/(1 - a + b), a <= # <= b}}, 0) & ) $] F.Function(F.Piecewise( F.List(F.List(F.Power(F.Plus(F.C1, F.Negate(a), b), -1), F.LessEqual(a, F.Slot1, b))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { IExpr[] minMax = minmax(dist); if (minMax != null) { IExpr a = minMax[0]; IExpr b = minMax[1]; IExpr function = // [$ Piecewise({{1/(b - a), a <= # <= b}}, 0)& $] F.Function(F.Piecewise( F.List(F.List(F.Power(F.Plus(F.Negate(a), b), -1), F.LessEqual(a, F.Slot1, b))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); // IExpr function = // [$ Piecewise({{GammaRegularized(1 + Floor(#), p), # >= 0}}, 0) & $] F.Function(F.Piecewise(F.List(F.List(F.GammaRegularized(F.Plus(F.C1, F.Floor(F.Slot1)), p), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr v = dist.arg1(); IExpr function = // [$ Piecewise({{GammaRegularized(v/2, 0, #/2), # > 0}}, 0) & $] F.Function(F.Piecewise( F.List(F.List(F.GammaRegularized(F.Times(F.C1D2, v), F.C0, F.Times(F.C1D2, F.Slot1)), F.Greater(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ (Piecewise({{GammaRegularized(n, 0, #*m), # > 0}}, 0)) & $] F.Function(F.Piecewise(F.List( F.List(F.GammaRegularized(n, F.C0, F.Times(F.Slot1, m)), F.Greater(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr n = dist.arg1(); // IExpr function = // [$ (Piecewise({{(1 - n)^#*n, # >= 0}}, 0)) & $] F.Function(F.Piecewise(F.List(F.List(F.Times(F.Power(F.Plus(F.C1, F.Negate(n)), F.Slot1), n), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr n = dist.arg1(); // IExpr function = // [$ Piecewise({{n/E^(#*n), # >= 0}}, 0) & $] F.Function(F.Piecewise(F.List(F.List(F.Times(F.Power(F.Exp(F.Times(F.Slot1, n)), -1), n), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); // IExpr function = // [$ Piecewise({{1 - p, # == 0}, {p, # == 1}}, 0) & $] F.Function(F.Piecewise(F.List(F.List(F.Plus(F.C1, F.Negate(p)), F.Equal(F.Slot1, F.C0)), F.List(p, F.Equal(F.Slot1, F.C1))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr n = dist.arg1(); IExpr function = // [$ (Piecewise({{1 - E^((-#)*n), # >= 0}}, 0)) & $] F.Function(F.Piecewise(F.List(F.List(F.Plus(F.C1, F.Negate(F.Exp(F.Times(F.CN1, F.Slot1, n)))), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); // Piecewise({{1 - E^((-k)*n), k >= 0}}, 0) // return F.Piecewise(F.List( // F.List(F.Plus(F.C1, F.Negate(F.Power(F.E, F.Times(F.CN1, k, n)))), F.GreaterEqual(k, F.C0))), // F.C0); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ Piecewise({{GammaRegularized(n, 0, (#^2*n)/m), # > 0}}, 0) & $] F.Function(F.Piecewise( F.List(F.List(F.GammaRegularized(n, F.C0, F.Times(F.Power(m, -1), n, F.Sqr(F.Slot1))), F.Greater(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ (1 - E^(-E^((# - n)/m))) & $] F.Function(F.Plus(F.C1, F.Negate( F.Exp(F.Negate(F.Exp(F.Times(F.Power(m, -1), F.Plus(F.Negate(n), F.Slot1)))))))); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); // IExpr function = // [$ Piecewise({{p^#/(E ^ p * #!), # >= 0}}, 0) & $] F.Function(F.Piecewise(F.List(F.List( F.Times(F.Power(p, F.Slot1), F.Power(F.Times(F.Exp(p), F.Factorial(F.Slot1)), -1)), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr p = dist.arg1(); IExpr function = // [$ (Piecewise({{0, # < 0}, {1 - p, 0<=#<1 }}, 1)) & $] F.Function( F.Piecewise( F.List(F.List(F.C0, F.Less(F.Slot1, F.C0)), F.List(F.Plus(F.C1, F.Negate(p)), F.And(F.LessEqual(F.C0, F.Slot1), F.Less(F.Slot1, F.C1)))), F.C1)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr n = dist.arg1(); IExpr function = // [$ (Piecewise({{1 - (1 - n)^(1 + Floor(#)), # >= 0}}, 0)) & $] F.Function( F.Piecewise(F.List(F.List( F.Plus(F.C1, F.Negate(F.Power(F.Plus(F.C1, F.Negate(n)), F.Plus(F.C1, F.Floor(F.Slot1))))), F.GreaterEqual(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ (Piecewise({{E^(-(#/m)^(-n)), # > 0}}, 0)) & $] F.Function(F.Piecewise( F.List(F.List(F.Exp(F.Negate(F.Power(F.Times(F.Power(m, -1), F.Slot1), F.Negate(n)))), F.Greater(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr cdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ Piecewise({{BetaRegularized((#*n)/(m + #*n), n/2, m/2), # > 0}}, 0) & $] F.Function(F.Piecewise(F.List(F.List( F.BetaRegularized(F.Times(n, F.Power(F.Plus(m, F.Times(F.Slot1, n)), -1), F.Slot1), F.Times(F.C1D2, n), F.Times(F.C1D2, m)), F.Greater(F.Slot1, F.C0))), F.C0)); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST1()) { IExpr n = dist.arg1(); // IExpr function = // [$ (n/(#^2 + n))^((1 + n)/2)/(Sqrt(n)*Beta(n/2, 1/2)) & $] F.Function(F.Times( F.Power(F.Times(n, F.Power(F.Plus(F.Sqr(F.Slot1), n), -1)), F.Times(F.C1D2, F.Plus(F.C1, n))), F.Power(F.Times(F.Sqrt(n), F.Beta(F.Times(F.C1D2, n), F.C1D2)), -1))); // $$; return callFunction(function, k); } return F.NIL; }
@Override public IExpr pdf(IAST dist, IExpr k) { if (dist.isAST2()) { IExpr n = dist.arg1(); IExpr m = dist.arg2(); IExpr function = // [$ (E^(-E^((# - n)/m) + (# - n)/m)/m) & $] F.Function(F.Times( F.Exp(F.Plus(F.Negate(F.Exp(F.Times(F.Power(m, -1), F.Plus(F.Negate(n), F.Slot1)))), F.Times(F.Power(m, -1), F.Plus(F.Negate(n), F.Slot1)))), F.Power(m, -1))); // $$; return callFunction(function, k); } return F.NIL; }