PDFFUN Apply a function to a set of probability distributions
[S,P,C]=PDFFUN(FUN,VARARGIN) will return the distribution of the function FUN applied to the set of distributions given in VARARGIN
The output vectors, S, P, and C, are respectively the list of unique outcomes, probability of yielding that outcome, and the total number of ways of obtaining that outcome among all combinations.
FUN can either be a function handle for an arbitrary function that takes one input argument and returns a scalar value, or one of the following built-in functions:
Valid for any number of distributions:
@plus, @sum, @add Sum
@mean, @average Average
Valid for only two distributions:
FUN as a user-specified arbitrary function handle is only valid for a single distribution.
VARARGIN is a list of distributions in the form of (X1,P1,N1,X2,P2,N2,...). Where Xn is the possible events for the n'th distribution, with probability Pn, repeated Nn times. The Nn values are needed if the function is valid for any number of distributions, listed above; otherwise it is not needed and assumed to equal one.
Valid for any number of distributions
Distribution of the maximum value when choosing five values
from distribution (A) and three from distribution (B)
x1=[-1 0 2]; p1=[.7 .2 .1]; n1=5; %(A)
x2=[-4 0 1 2]; p2=[.1 .5 .3 .1]; n2=3; %(B)
Valid for only two distributions
Difference of two different distributions, A and B
x1=[-1 0 2]; p1=[.7 .2 .1]; %(A)
x2=[-4 0 1 2]; p2=[.1 .5 .3 .1]; %(B)
Difference of a distribution with itself
x1=[-1 0 2]; p1=[.7 .2 .1];
x1=[-2 -1 0 1]; p1=[.05 .7 .2 .05];
Note: Program assumes discrete distribution. If using continuous distributions, and using densities as inputs, a normalization must be made afterwards. Also, as only a finite number of points are used the results are an approximation to the actual value on a valid domain.
Distribution of the minimum of five standard normal distributions.
(This example requires the statistics toolbox)
P1=P1./trapz(S1,P1); %Convert to density
plot(S1,P1,x1,y1), grid on