0
$\begingroup$
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?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – ciao Jan 17 '14 at 8:39
1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ can we plot this CDF combinedly for different values of 'n'that i fixed to 20.. $\endgroup$ – user11609 Jan 17 '14 at 11:13
  • $\begingroup$ @user11609 yes. Just redefine function to:cdfgeneral[n_,k_]:=Sum[PrDEqK[P, K, n, c, j], {j, 0, k}]; $\endgroup$ – ubpdqn Jan 17 '14 at 11:16
  • $\begingroup$ okk...thank u so much.. $\endgroup$ – user11609 Jan 17 '14 at 11:20
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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