# PDF of binomial distribution and mixed binomial distribution

I want to plot the PDF of binomial distributed function and a mixed binomial distributed function, therefore I entered for the binomial distribution function the following:

Remove["Global*"];
m = 45; (*number of banks*)
n = 5;(*number of defaults*)
AssetV = 100;(*asset value at T*)
DebtV = 80;(*debt value at T*)
μ = 0.2;(*annual drift*)
σ = 0.3;(*annual volatility*)
T = 5;(*years*)
ρ = 0.8; (*asset correlation*)

(*calculation of the individual default probabiltiy p^*, which is \
determined based on the Merton model*)

P* = (CDF[
NormalDistribution[], -(Log[
AssetV/DebtV] + (μ - 0.5*σ^2)*T)/(σ*Sqrt[
T])])
(*generating data table, which captures the probabilities that the \
number of defaults will be greater than n1, whereas n1 encompasses \
the range from 0 to m by the step of 1 (integer)*)

dataBD = Table[
Probability[x >= n1,
x \[Distributed] BinomialDistribution[m,  P*]], {n1, 0, m,
1}]


now I want to plot everything:

pdfBD = DiscretePlot[
PDF[BinomialDistribution[m, P*], n1], {n1, 0, m},
PlotRange -> All, AxesLabel -> {"# of Defaults", "PD"},
Joined -> True, ImageSize -> 500]


so I get this plot

now I want to consider the mixed binomial distribution, determiend by the following code:

dataMBD =
Table[1 -
CDF[NormalDistribution[], ((1/
Sqrt[ρ])*(((Sqrt[
1 - ρ])*(InverseCDF[
NormalDistribution[], (n1/m)]) + (InverseCDF[
NormalDistribution[], (CDF[
NormalDistribution[], -(Log[
AssetV/DebtV] + (μ - 0.5*σ^2)*
T)/(σ*Sqrt[T])])]))))], {n1, 0, m, 1}]


However, if I want to see its PDF and if I therefore enter this command it does not work:

DiscretePlot[PDF[dataMBD, n1], {n1, 0, m, 1}]


Is the error within the command above, or is there a fundamental problem based on wrong understanding?

hope somebody can help me. thanks.

-
I think this post might help. –  Rod Jul 26 '13 at 14:44
@RodLm thanks, I tried to figure it out, it still does not work the way I want it, can you give me one more hint? –  Milan Ivica Jul 26 '13 at 15:52
dataMBD is not a pmf (or pdf as you call it). It is just a table of values {1, 0.99, 0.98, ..., 0.96, ..., 0.74, ..., 0}. It is not a distribution. PDF[dataMBD, blah] makes no sense. –  wolfies Jul 26 '13 at 16:10
@wolfies thank you. I just do not understand how pdfBD = DiscretePlot[PDF[BinomialDistribution[...]] works. because I use the BinomialDistribution to calculate the probability that e.g. x>=5, I do the same with the mixed binomial distribudion. is there any possibility to graphically compare pdfBD = DiscretePlot[PDF[BinomialDistribution[...]], and the density of the results based on the mixed binomial distribution? –  Milan Ivica Jul 27 '13 at 5:59
I think instead of discrete plot, you can simply use ListlinePlot[dataMBD], hope it'll be useful to some extend. –  Abdul Haq Nov 2 '13 at 8:28

First the P* that shows up in your code isn't a valid symbol, but I'll assume this is a typesetting issue or copying since you did get the first plot to work.

Probably not a complete answer, but you should look at SmoothKernelDistribution which will allow you to convert dataMBD into a distribution:

dist = SmoothKernelDistribution[dataMBD];
Plot[PDF[dist, n1], {n1, 0, 2}, PlotRange -> All]


You'll take a performance hit if you try to do something like Plot[PDF[SmoothKernelDistribution[dataMBD], n1], {n1, 0, 2}, PlotRange -> All] so define the distribution outside of Plot`.

-
Hmm, Just noticed this was asked ages ago and the OP has likely moved on... –  bobthechemist Jan 1 '14 at 13:19
the story of my life! :-) –  chris May 1 '14 at 17:13