0
$\begingroup$

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

enter image description here

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.

$\endgroup$
5
  • $\begingroup$ I think this post might help. $\endgroup$
    – Rod
    Jul 26, 2013 at 14:44
  • $\begingroup$ @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? $\endgroup$ Jul 26, 2013 at 15:52
  • 1
    $\begingroup$ 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. $\endgroup$
    – wolfies
    Jul 26, 2013 at 16:10
  • $\begingroup$ @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? $\endgroup$ Jul 27, 2013 at 5:59
  • $\begingroup$ I think instead of discrete plot, you can simply use ListlinePlot[dataMBD], hope it'll be useful to some extend. $\endgroup$
    – Abdul Haq
    Nov 2, 2013 at 8:28

1 Answer 1

2
$\begingroup$

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]

Mathematica graphics

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.

$\endgroup$
2
  • $\begingroup$ Hmm, Just noticed this was asked ages ago and the OP has likely moved on... $\endgroup$ Jan 1, 2014 at 13:19
  • $\begingroup$ the story of my life! :-) $\endgroup$
    – chris
    May 1, 2014 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.