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.

I hope one of you guys can help me out. I am trying to visualize a discrete distribution based on a binomial distribution and a mixed binomial distribution.

In the first step I started to determine the parameters:

Remove["Global`*"];
m = 45; (*total number*)
n = 3;  (*target number*)
AV = 55605000;
DV = 52474000;
μ = 0.06
σ = 0.10;
T = 5;
ρ = 0.22; 

Then I started with the binomial distribution which is given by Mathematica. In order to calculate the probability that x ≥ 3, I need the single probability which is calculated by:

p = (CDF[NormalDistribution[], -(Log[AV/tV] + (μ - 0.5*σ^2)*T)/(σ*Sqrt[T])])

the result for p is 0.068

than I want to calculate the probability that x ≥ 3 to to so I enter the following:

probBDAW = Probability[x >= 3, x \[Distributed] BinomialDistribution[m, p]]

and the result is 0.60.

then I want to have a table of the probabilites when x≥1,x≥2,≥´x≥3..etc...in order to do so I entered this:

dataBDAW = 
 Table[Probability[x >= n1, x \[Distributed] BinomialDistribution[m, p]], {n1, 0, 45, 1}]

this also works and I get a table.

In the next step I want to plot the discrete distribution of this probabilites by using the DiscretPlot function. Therefore I enter:

pdfBDAWXX = 
  DiscretePlot[
    PDF[BinomialDistribution[m, p]], n1], {n1, 0, m}, 
    PlotRange -> All, AxesLabel -> {"y", "x"}, ImageSize -> 500, 
    PlotLabel -> Style["Text", Bold]]

this also works well and I get the follwoing chart:

enter image description here

Now I want to use a mixed binomial set up.

I already calculated p so want to calculate again that x ≥ 3. To do so I enter:

probMBD = 
 1 - CDF[NormalDistribution[], ((1/Sqrt[
       1 - ρ])*(((Sqrt[ρ])*(InverseCDF[
           NormalDistribution[], (3/m)]) - (InverseCDF[
          NormalDistribution[], (CDF[
            NormalDistribution[], -(Log[
                 AV/DV] + (μ - 
                   0.5*σ^2)*
                 T)/(σ*Sqrt[T])])]))))]

thus I get the probability that x ≥ 3 is 0.187

as before I want to generate a list with the probabiliest x≥1,x≥2,≥x≥3..etc. Hence I enter:

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

As a result I get a nice table. But when I want to plot the discrete distribution I have some problems. I did something but I am far from sure that this is right. so could please anyone look at this and say if it is corret and if not could you please write me how it is done correctly?

ok so I just said that

testx = (dataMBDAW)

then I wrote this function in oder do caputre the discrete density:

ftest[jk_] := testx[[jk]] + testx[[jk + 1]]

In the next step I did the following:

H1 = 
 ListPlot[Table[testx[[jk]] + testx[[jk + 1]], {jk, 2, 45}], 
   PlotStyle -> Black, PlotRange -> All, AxesLabel -> {"y", "x"}, 
   ImageSize -> 500, PlotLabel -> Style["text", Bold], Filling -> Axis,
   FillingStyle -> Directive[Opacity[0.2], Black]]

and the result is this chart:

enter image description here

I am not sure if this is correctly done. I would be thankful if you could help me out and say if it is correct and if not provide me with a solution for my problem.

share|improve this question
    
Perhaps MixtureDistribution is what you're looking for. –  ybeltukov Oct 3 '13 at 19:03
    
@ybeltukov Thanks, and how would you apply it exactly? –  Milan Ivica Oct 3 '13 at 20:18
2  
Too many irrelevancies. What we want in posted code is a minimal example of the problem to be solved. The posted code should be free of all irrelevancies, but a lot of what you posted is irrelevant. –  m_goldberg Oct 6 '13 at 3:36

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.