1
$\begingroup$

Is there a quick way to draw a probability histogram as e.g. here or here, page 166, say for a binomial distribution, with the bases of the rectangles centered at the integers and no spacing between the rectangles? In the book at the second link, they use Needs["KnoxProbUtilities"], but this does not seem to be working now (in Mathematica 12).

$\endgroup$
2
$\begingroup$

If you want exact probabilities:

BarChart[
 PDF[BinomialDistribution[4, .5], r=Range[0, 4]],
 BarSpacing -> None,
 ChartLabels -> r]

enter image description here

| improve this answer | |
$\endgroup$
1
$\begingroup$
pdf = PDF[BinomialDistribution[4, .5]];

DiscretePlot

DiscretePlot[pdf@x, {x, 0, 4}, ExtentSize -> Full]

enter image description here

Histogram with custom heights

heights = pdf /@ Range[0, 4] &;
binning = {-.5, 4.5, 1};

Histogram[{1}, binning, heights]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you for your answer. +1 $\endgroup$ – Iosif Pinelis Mar 18 at 13:20

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.