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.
c = 2;
P = N[n*Log[n]]
K = N[c*Log[n]]

Needs["PlotLegends`"];

PrDEqK[P_, K_, n_, c_, k_] := Module[{p, q, r, ps, qs, m, tmp},
    r = Sqrt[(c*Log[n])/(n*\[Pi])];
    p = \[Pi]*r^2;
    q = 1 - p;
    ps = 1 - Binomial[P - K, K]/Binomial[P, K];
    qs = 1 - ps;

   N[Sum[Binomial[n - 1, m]*p^m*q^(n - 1 - m)*Binomial[m, k]*ps^k*
      qs^(m - k), {m, k, n - 1}]]

   ];
Plot[CDF[{PrDEqK[P, K, 20, c, k], {k, 1, 8},Filling -> Axis
]

i'm not getting the CDF plot...what is the problem?

share|improve this question
    
CDF, for one thing, is for distributions, you are trying to plot a function. There are other issues with the code, please attempt to fix these and add some context to the question. –  rasher Jan 17 at 8:39

2 Answers 2

up vote 1 down vote accepted

As has been CDF acts on distribution objects. You have defined a discrete PMF. With all due respect the plot by Boson is not a CDF but a continous plot of PMF.

Reproduing user-defined:

c = 2;
n = 20;
P = N[n*Log[n]];
K = N[c*Log[n]];

PrDEqK[P_, K_, n_, c_, k_] := 
  Module[{p, q, r, ps, qs, m, tmp}, r = Sqrt[(c*Log[n])/(n*\[Pi])];
   p = \[Pi]*r^2;
   q = 1 - p;
   ps = 1 - Binomial[P - K, K]/Binomial[P, K];
   qs = 1 - ps;
   N[Sum[Binomial[n - 1, m]*p^m*q^(n - 1 - m)*Binomial[m, k]*ps^k*
      qs^(m - k), {m, k, n - 1}]]];

To generate CDF:

cdf[k_] := Sum[PrDEqK[P, K, 20, c, j], {j, 0, k}];

Visualizing:

DiscretePlot[cdf[k], {k, 0, 8}]

enter image description here

share|improve this answer
    
thank you all... –  user11609 Jan 17 at 9:39
    
can we plot this CDF combinedly for different values of 'n'that i fixed to 20.. –  user11609 Jan 17 at 11:13
    
@user11609 yes. Just redefine function to:cdfgeneral[n_,k_]:=Sum[PrDEqK[P, K, n, c, j], {j, 0, k}]; –  ubpdqn Jan 17 at 11:16
    
okk...thank u so much.. –  user11609 Jan 17 at 11:20

I tried to clean your code a little and it worked right away:

c = 2;
n = 20;
P = N[n*Log[n]];
K = N[c*Log[n]];

PrDEqK[P_, K_, n_, c_, k_] := 
  Module[{p, q, r, ps, qs, m, tmp}, r = Sqrt[(c*Log[n])/(n*\[Pi])];
   p = \[Pi]*r^2;
   q = 1 - p;
   ps = 1 - Binomial[P - K, K]/Binomial[P, K];
   qs = 1 - ps;
   N[Sum[Binomial[n - 1, m]*p^m*q^(n - 1 - m)*Binomial[m, k]*ps^k*
      qs^(m - k), {m, k, n - 1}]]];

Plot[PrDEqK[P, K, n, c, k], {k, 1, 8}, Filling -> Axis]

enter image description here

EDIT: I am sorry, I have not read the question thoroughly and did not notice you wanted a CDF. ubpdqn is absolutly right.

share|improve this answer

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.