I'm trying to plot the CDF of a simple "nCr" experiment:

A box contains 4 screws and 6 nails. Two items are drawn at random without replacement. Let X be the number of nails drawn.

I built a piecewise function:

`F[x_] := \[Piecewise] {
 {12/90, 0 <= x <= 1},
 {60/90, 1 <= x <= 2},
 {1, x >= 2},
 {0, True}

which outputs an unexpected "shift": enter image description here

which I can 'band-aid fix' by plotting F(x+1) in the 'DiscretePlot' function.

enter image description here

Am I thinking about the CDF function incorrectly? Is there another way to build and plot F?

  • $\begingroup$ Simply use: Plot[F[x], {x, 0, 3}] and do not use capital variable names, they are reserved for built in functions. $\endgroup$ Dec 7, 2021 at 9:31
  • $\begingroup$ Have you already seen EmpiricalDistribution[]? $\endgroup$ Dec 7, 2021 at 18:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.