Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Hi I just want to flatten a function, I tied it with Joined->True, but it did not work, hope somebody of you can help me.

This is my code:

Remove["Global`*"]
m = 30; (*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;

Since I want to use a BinomialDistribution I calculated the individual probabilities through:

P = (CDF[NormalDistribution[], -(Log[
        AssetV/DebtV] + (μ - 0.5*σ^2)*T)/(σ*Sqrt[
      T])])

In the following I generated a table where I wanted to see the probabilities where k=n1, varies from 0 to 30 since n=30, and this is given by:

data1 = Table[
  Probability[x >= n1, 
   x \[Distributed] BinomialDistribution[30, P]], {n1, 0, 30, 1}]

In order to plot the probabilities I entered:

Plot[Probability[x >= n1, 
  x \[Distributed] BinomialDistribution[30, P]], {n1, 0, 30}, 
 PlotRange -> All, AxesLabel -> {"# of Defaults", "PD"}, 
 Filling -> Axis]

and now I just want to flatten this function. I tried it with Joined-True, which did not work out.

I want also to show the density by:

DiscretePlot[PDF[BinomialDistribution[30, P], n1], {n1, 0, 30}, 
 PlotRange -> All, AxesLabel -> {"# of Defaults", "PD"}, 
 Joined -> True]

However, is there the possibility to implement data1=Table[...] into the two functions, would it be then possible to generate the plot by the ListLinePlot function?

thank you for your help.

share|improve this question
    
is your question on how to combine plots? –  Stefan Jul 23 '13 at 8:26
    
@Stefan no my question is, how to flatten the plot given by Plot[Probability[...]] and if it is possible to implement data1 into Plot[Probability[...]]. –  Milan Ivica Jul 23 '13 at 8:28
    
@Nasser I want the results from Plot[Probability[...]] to be a combined/connected line –  Milan Ivica Jul 23 '13 at 8:28
    
Perhaps Exclusions -> None is the option you're looking for? –  Simon Woods Jul 23 '13 at 8:39

1 Answer 1

up vote 3 down vote accepted

You mean like this? (no place to put in comment, will remove if not)

 data = Table[{n1, 
    Probability[x >= n1, 
     x \[Distributed] BinomialDistribution[30, P]]}, {n1, 0, 20}];
ListPlot[data, Joined -> True, Mesh -> True, PlotRange -> All, 
  Frame -> True, PlotStyle -> PointSize[.02], GridLines -> Automatic, 
  GridLinesStyle -> LightGray]

enter image description here

side-by-side

enter image description here

share|improve this answer
    
@ Nasser thank you, that was exactly what I was looking for –  Milan Ivica Jul 23 '13 at 8:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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