%mathpiper,def="Expectation"

/* Evaluates distribution dst at point x
   known distributions are:
   1. Discrete distributions
   -- BernoulliDistribution(p)
   -- BinomialDistribution(p,n)
   -- DiscreteUniformDistribution(a,b)
   -- PoissonDistribution(l)
   2. Continuous distributions
   -- ExponentialDistribution(l)
   -- NormalDistrobution(a,s)
   -- ContinuousUniformDistribution(a,b)
   -- tDistribution(m)
   -- GammaDistribution(m)
   -- ChiSquareDistribution(m)

  DiscreteDistribution(domain,probabilities) represent arbitrary
  distribution with finite number of possible values; domain list
  contains possible values such that
  Pr(X=domain[i])=probabilities[i].
  TODO: Should domain contain numbers only?
*/



10 # Expectation(BernoulliDistribution(_p)) <-- 1-p;

10 # Expectation(BinomialDistribution(_p,_n)) <-- n*p;

10 # Expectation( DiscreteDistribution( dom_IsList, prob_IsList))_( Length(dom)=Length(prob) And Simplify(Sum(prob))=1) <-- Sum @ {i,1,Length(dom),dom[i]*prob[i]};


%/mathpiper




%mathpiper_docs,name="Expectation",categories="User Functions;Statistics & Probability"
*CMD Expectation --- expectation function
*STD
*CALL
	Expectation(p)
        Expectation(p,n)

*PARMS
{p} -- number, probability of an event in a single trial

{n} -- number of trials


*SEE CDF, PDF
%/mathpiper_docs