Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question


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

share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer


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.