# Histogram "PDF" vs "Probability"

I have a discrete random variable with values from $0$ to $100$. I have plotted its histogram with bars centered in $0, 5, 10,\dots,100$. First I made the histogram using the "PDF" option,

But I notice that the sum of values (height) of, for example, bars $\ge 70$ only sums $0.086$. And therefore, I do not know if the $y$-axis should say probability.

After that, I have used option "Probability".

In this case, the bars sum to $1$ which indicates that each bar has its value of probability.

I know this can be more a mathematical question than a question about the Mathematica language, but I do not understand the difference between the two options, "PDF" and "Probability". Besides, I do not know how to label the $y$-axis. What label results are more appropriate? Probability? Density? Relative frequency?

Thank you very much for your help.

I believe that when you specify "PDF", the value on the ordinate is the average probability density within a given bin. And to get the "within-this-bin" probability, you need to multiply the ordinate by the bin width (5 in this case); and that's what you get when you specify the "Probability" option.

• Thank you is correct Aug 15, 2017 at 20:34
• An additional note that others might find useful for when trying to use the "Count" option in Histogram. To get a continuous PDF to match, scale the density function by (binWidth * Length[data]) Oct 20, 2017 at 17:24

Mathematica and Wolfram Language are knowledge-based. The structure is that Histogram in general is independent of the options and distributions.

If a known distribution is entered in Histogram than some options make sense.

So use an example from the documentation page of Histogram:

Histogram[
RandomVariate[WeibullDistribution[2, 1],
1000], Automatic, "Probability"]


Histogram[
RandomVariate[WeibullDistribution[2, 1], 1000], Automatic, "PDF"]


So Probability is really different from PDF in the output values.

Probability is too available as a standalone built-in. It simulates numerical outputs of computer simulations or experiments for the implemented distributions.

PDF is a built-in function too. It has two arguments: distribution and value. PDF is an acronym for probability density function. This seems to be very similar at first sigh. It does not need a continuum of input values.

Probabilities are usually expressed as quotients. This makes them from the fundamental viewpoint of mathematics really closely related to densities, but they are usually dimensionless. That can be used as a criterion for checking if one has calculated probabilities.

A probability density is divided into the variates interval as a probability. The interval can be a line, a surface, a volume, or something more complicated.

The documentation page for PDF does not show the Histogram as an example. Wolfram Inc prefers the DiscretePlot built-in. And they show the relation between the PDF and the CDF, cumulative density function of a distribution. The PDF is the derivative of the CDF. And the CDF is much more related to the Probability option in the given question. But still, both are not the same.

All is based on very fundamental concepts of probes. The distributions theory relies on the most advanced and complex axioms. Histogram is not part of any of those concepts. It is related to BinCounts. That is more fundamental than Probability, Expectation, and Mean, Variation, and alike. So the option Probability raises the requirements to the Histogram built-in very much and PDf does this too up to a higher theoretical level of requirements.

Each steps needs a semester of study to master them. Mathematica is not designed closed to opaque for the theoretical requirements demands. You are allowed to mix up.

Each documentation page ends in a suggestion and a built-in list. So BinCount is a link from Histogram to PDF and PDF has already Probability and Histogram in the list.

This question addresses one major problem of CAS in general. Should dimension be implemented and how strict should they be used. This problem is inherent in the logic of the heuristics in the theories used the named built-ins of this answer. In Mathematica, the user has to keep track of dimensions and is supported if he uses them consequently.

Mathematica offers QuantityDistribution for those interested. If there is no unit but uncertainty, I recommend using a unit in QuantityDistribution. It is allowed in Mathematica to use IndependentUnit. There is much knowledge implemented in Mathematica helping for certainty. Event the built-in IndependentPhysicalQuantity can be used.

IndependentPhysicalQuantity[string]


represents a physical quantity string with no relationship to other physical quantities used in QuantityVariable.

The histogram in the first case has to be labeled PDF on the left and in the second case it is correctly labeled Probability. Wolfram Inc. saved up till today on labeling so many graphics in their documentation. It is a shame and to blame. Even the option AxesLabel exists but with the value Automatic nothing happens.

Histogram[
RandomVariate[WeibullDistribution[2, 1],
1000], Automatic, "Probability",
AxesLabel -> {"Independent Variable", "Probability"}]


Histogram[
RandomVariate[WeibullDistribution[2, 1], 1000], Automatic, "PDF",
AxesLabel -> {"Variate", "PDF"}]