1
$\begingroup$

How can I get the CDF for a list of values ​​containing the value of a random variable and its probability?

I have:

grs[n_] := If[n == 14, 0.9^(n - 1)*0.1 + 0.9^14, 0.9^(n - 1)*0.1]

tableOfRandomVariable = Table[{n, grs[n]}, {n, 1, 14}]

hDist = HistogramDistribution[tableOfRandomVariable];

DiscretePlot[CDF[hDist, x], {x, 0, 14}, ExtentSize -> Right, ExtentMarkers -> {"Filled", "Empty"}]

It is not works.

When i try to do:

grs[n_] := If[n == 14, 0.9^(n - 1)*0.1 + 0.9^14, 0.9^(n - 1)*0.1]

tableOfRandomVariable = Table[grs[n], {n, 1, 14}] (*This list not contain random values, only probability list*)

hDist = HistogramDistribution[tableOfRandomVariable];

DiscretePlot[CDF[hDist, x], {x, 0, 14}, ExtentSize -> Right, ExtentMarkers -> {"Filled", "Empty"}]

I expect about:

Expected output

But mathematica gives:

Wrong output

How I can get CDF plot for first table of variables?

$\endgroup$
2
$\begingroup$
dist = EmpiricalDistribution[
  tableOfRandomVariable[[All, 2]] -> tableOfRandomVariable[[All, 1]]];

DiscretePlot[CDF[dist, x], {x, 0, 14}, ExtentSize -> Right, 
 ExtentMarkers -> {"Filled", "Empty"}]

enter image description here

$\endgroup$
0

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.