1
$\begingroup$

I have a list of numbers and I want to plot the fraction of numbers >= k against k which will naturally be a decreasing curve. How do I do that?

$\endgroup$
2
$\begingroup$

E.g.:

test = RandomInteger[100, 100];

ListLinePlot[With[{r = Reverse@Sort@Tally[test]}, 
  Transpose[{Reverse@r[[All, 1]], Reverse@Accumulate@r[[All, 2]]}]]]

enter image description here

$\endgroup$
2
$\begingroup$

You mean something like this?

list = RandomVariate[BinomialDistribution[100, 0.1], {10000}];

You can use list to construct an EmpiricalDistribution, and then use DiscretePlot (if the list is all integers) or Plot (if it's reals) to plot the complement of its CDF.

dist = EmpiricalDistribution[list];

DiscretePlot[1 - CDF[dist, x], {x, 0, 100}, PlotRange -> All]

plot of CDF's complement

$\endgroup$
2
$\begingroup$

Few more alternatives/variations:

data = RandomReal[50, 100];
  1. HistogramList with height spec "SF":

    ListLinePlot[#, PlotRange -> {{0, 60}, Automatic}]&@Thread@PadRight@HistogramList[data, 1000, "SF"]

  2. SurvivalFunction and EmpiricialDistribution

    Plot[SurvivalFunction[EmpiricalDistribution[data], x], {x, 0, 60}, Exclusions -> None]

  3. Plain old Histogram with height spec "SF"

    Histogram[data, 1000, "SF", PlotRange -> {{0, 60}, Automatic}];

enter image description here

$\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.