Calculator Inputs
Example Data Table
| Case | Chemistry use | Posterior model | Inputs | Credible mass |
|---|---|---|---|---|
| A | Assay concentration estimate | Normal | Mean 12.5, SD 1.2 | 95% |
| B | Reaction conversion fraction | Beta | Alpha 22, Beta 8 | 95% |
| C | Positive reaction rate | Gamma | Shape 16, Rate 2.4 | 90% |
| D | MCMC posterior output | Samples | Comma separated values | 95% |
Formula Used
The HPD region contains points with the highest posterior density until the required posterior mass is reached.
HPD set: R = { θ : p(θ | y) ≥ c }
Credible mass: ∫R p(θ | y)dθ = 1 − α
Normal density: p(θ) = exp[-(θ − μ)² / (2σ²)] / (σ√(2π))
Beta density: p(θ) = θa−1(1−θ)b−1 / B(a,b)
Gamma rate density: p(θ) = rkθk−1exp(−rθ) / Γ(k)
For samples, the calculator selects the shortest interval containing the chosen posterior mass.
How to Use This Calculator
Select the posterior model that matches your chemistry problem. Use normal for symmetric concentration estimates. Use beta for fractions, purity, yield, or conversion. Use gamma for positive rates, decay constants, or variance-like parameters. Use empirical samples when you have MCMC output.
Enter the credible mass. A common value is 95%. Add units for clearer exported reports. Leave grid limits blank unless the automatic range misses important tail mass. Increase grid points for smoother numerical results.
Press the calculate button. The HPD result appears above the form and below the header. Use the CSV or PDF buttons to save the final result.
Highest Posterior Density Region in Chemistry
Bayesian Interval Meaning
A highest posterior density region is a Bayesian interval. It reports the most credible parameter values after data and prior information are combined. In chemistry, this can support assay validation, kinetic fitting, calibration, and uncertainty review. The method is useful when a single estimate is not enough. It describes where the parameter is most supported by the posterior distribution.
Why HPD Regions Help
A common credible interval may include low density values. An HPD region avoids that weakness. It keeps the densest values first. Then it expands until the selected posterior probability is reached. This gives a compact summary. It is often shorter than an equal tail interval. It also works well for skewed posteriors. Many chemical values are skewed because they cannot fall below zero.
Choosing a Posterior Model
The normal model is useful for repeated measurements with near symmetric error. Concentration, pH adjustment residuals, and instrument calibration slopes may fit this case. The beta model is better for bounded values. Examples include conversion, yield fraction, purity fraction, or probability of detection. The gamma model handles positive quantities. It is helpful for rate constants, scale values, and positive response parameters.
Grid and Sample Methods
This calculator uses two practical methods. For known posterior families, it builds a dense grid. It evaluates density at each grid point. It sorts points from high density to low density. Then it keeps enough points to match the chosen credible mass. For posterior samples, it sorts the samples and finds the shortest interval that contains the requested mass.
Reading the Output
The lower and upper bounds define the reported HPD region. The width shows uncertainty size. The mode gives the most dense value. The density cutoff is the boundary level for grid models. Values above that cutoff belong inside the HPD set. Values below it are outside. Use the captured mass to check numerical accuracy.
Reporting Results
Report the model, parameters, credible mass, and units. Include the grid range when limits were custom. For regulatory or laboratory records, keep exported CSV and PDF files with the analysis notebook. Always compare the interval with chemical knowledge. A result can be numerically correct but chemically unrealistic when the model is poor.
FAQs
What is a highest posterior density region?
It is the set of parameter values with the highest posterior density. It contains the chosen probability mass, such as 95%. It gives a compact Bayesian uncertainty region.
Is an HPD region the same as a confidence interval?
No. An HPD region is Bayesian and uses a posterior distribution. A confidence interval is usually frequentist. Their meanings and assumptions are different.
Which model should I use for concentration data?
Use the normal model when errors are symmetric and the concentration is far from zero. Use gamma when the value is positive and skewed.
When should I use the beta model?
Use the beta model for bounded chemical fractions. It fits yield, purity, reaction conversion, and probability-like values between zero and one.
What does the density cutoff mean?
The cutoff is the minimum posterior density inside the HPD region. Points with density above it are included in the region.
Why does the sample method use the shortest interval?
Posterior samples do not have a direct density formula. The shortest interval gives a practical HPD approximation for one-dimensional sampled values.
Can the HPD region have multiple intervals?
Yes. A multimodal posterior can produce separated HPD intervals. This calculator supports multiple intervals for grid-based density calculations.
Should I increase grid points?
Increase grid points when the posterior is narrow, skewed, or sensitive. More points usually improve accuracy but may take slightly longer.