# Probability histogram

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).

If you want exact probabilities:

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


pdf = PDF[BinomialDistribution[4, .5]];


### DiscretePlot

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


### Histogram with custom heights

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

Histogram[{1}, binning, heights]


• Thank you for your answer. +1 – Iosif Pinelis Mar 18 '20 at 13:20