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).
$\begingroup$
$\endgroup$
Add a comment
|
2 Answers
$\begingroup$
$\endgroup$
0
If you want exact probabilities:
BarChart[
PDF[BinomialDistribution[4, .5], r=Range[0, 4]],
BarSpacing -> None,
ChartLabels -> r]
$\begingroup$
$\endgroup$
1
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]
-
$\begingroup$ Thank you for your answer. +1 $\endgroup$ Commented Mar 18, 2020 at 13:20