Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the shortest interval that contains a give amount of probability mass
ResourceFunction["HighestDensityInterval"][dist, p] returns the shortest Interval for distribution dist that contains probability mass p. | |
ResourceFunction["HighestDensityInterval"][vec, p] returns the shortest Interval that contains at least fraction p of the values in numerical vector vec. |
Find the shortest interval that contains 90% of the probability mass of a GammaDistribution:
In[1]:= | ![]() |
Out[1]= | ![]() |
Verify that the interval contains 90% of the probability mass:
In[2]:= | ![]() |
Out[2]= | ![]() |
Check the length of the interval:
In[3]:= | ![]() |
Out[3]= | ![]() |
Show the probability contained in the interval:
In[4]:= | ![]() |
Out[4]= | ![]() |
Compute the interval using samples from the distribution:
In[5]:= | ![]() |
Out[5]= | ![]() |
The HighestDensityInterval can be used to detect and remove outliers:
In[6]:= | ![]() |
Out[7]= | ![]() |
Remove the outliers:
In[8]:= | ![]() |
Out[8]= | ![]() |
Compute the mean of the data without the outlier:
In[9]:= | ![]() |
Out[9]= | ![]() |
Wolfram Language 14.0 (January 2024) or above
This work is licensed under a Creative Commons Attribution 4.0 International License