Learn R Programming

boostmath

Providing simple access to Boost’s Math functions in R, no compilation required.

Installation

You can install the development version of boostmath from GitHub with:

# install.packages("remotes")
remotes::install_github("andrjohns/boostmath")

Or you can install pre-built binaries from R-Universe:

install.packages("boostmath", repos = c("https://andrjohns.r-universe.dev",
                                        "https://cran.r-project.org"))

Usage

Functions can be used directly after loading the package:

library(boostmath)
#> 
#> Attaching package: 'boostmath'
#> The following object is masked from 'package:grDevices':
#> 
#>     pdf
#> The following object is masked from 'package:base':
#> 
#>     mode

hypergeometric_pFq(c(1, 2.5), c(0.5, 2), 1)
#> [1] 6.675991
ibeta_inv(2.1, 5.2, 0.7)
#> [1] 0.361431
owens_t(2.1, 4.2)
#> [1] 0.00893221

Any Boost Math functions that share the same name as R functions are sufffixed with _boost to avoid conflicts:

beta_boost(3, 2)
#> [1] 0.08333333
lgamma_boost(5)
#> [1] 3.178054

Quadrature and Differentiation

Boost’s integration routines are also available for use with R functions:

trapezoidal(function(x) { 1/(5 - 4*cos(x)) }, a = 0, b = 2*pi)
#> [1] 2.094395

gauss_legendre(function(x) { x * x * atan(x) }, a = 0, b = 1, points = 20)
#> [1] 0.2106573

gauss_kronrod(function(x) { exp(-x * x / 2) }, a = 0, b = Inf, points = 15)
#> [1] 1.253314

As well as numerical differentiation by finite-differencing or the complex-step method:

finite_difference_derivative(exp, 1.7)
#> [1] 5.473947

complex_step_derivative(exp, 1.7)
#> [1] 5.473947

Distribution Functions

boostmath implements Boost’s approach of creating a distribution ‘object’ which the various distribution functions (e.g., pdf, quantile) can be applied:

# Normal distribution with mean = 0, sd = 1
dist <- normal_distribution(0, 1)
# Apply generic functions
cdf(dist, 0.5)
#> [1] 0.6914625
logcdf(dist, 0.5)
#> [1] -0.3689464
pdf(dist, 0.5)
#> [1] 0.3520653
logpdf(dist, 0.5)
#> [1] -1.043939
hazard(dist, 0.5)
#> [1] 1.141078
chf(dist, 0.5)
#> [1] 1.175912
mean(dist)
#> [1] 0
median(dist)
#> [1] 0
mode(dist)
#> [1] 0
range(dist)
#> [1] -Inf  Inf
quantile(dist, 0.2)
#> [1] -0.8416212
standard_deviation(dist)
#> [1] 1
support(dist)
#> [1] -Inf  Inf
variance(dist)
#> [1] 1
skewness(dist)
#> [1] 0
kurtosis(dist)
#> [1] 3
kurtosis_excess(dist)
#> [1] 0

Alternatively, the PDF, CDF, log-PDF, log-CDF, and quantile functions for statistical distributions can just be called directly:

beta_pdf(0.1, 1.2, 2.1)
#> [1] 1.569287

beta_lpdf(0.1, 1.2, 2.1)
#> [1] 0.4506213

beta_cdf(0.1, 1.2, 2.1)
#> [1] 0.1380638

beta_lcdf(0.1, 1.2, 2.1)
#> [1] -1.98004

beta_quantile(0.5, 1.2, 2.1)
#> [1] 0.3335097

Copy Link

Version

Install

install.packages('boostmath')

Monthly Downloads

236

Version

1.4.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Andrew Johnson

Last Published

December 15th, 2025

Functions in boostmath (1.4.0)

cardinal_quintic_hermite

Cardinal Quintic Hermite Interpolator
cardinal_quintic_b_spline

Cardinal Quintic B-Spline Interpolator
fisher_f_distribution

Fisher F Distribution Functions
chebyshev_polynomials

Chebyshev Polynomials and Related Functions
condition_numbers

Condition Numbers
chi_squared_distribution

Chi-Squared Distribution Functions
fp_utilities

Floating Point Utilities
gamma_distribution

Gamma Distribution Functions
catmull_rom

Catmull-Rom Interpolation
constants

Boost Math Constants
generic_distribution_functions

Generic Distribution Functions
gegenbauer_polynomials

Gegenbauer Polynomials and Related Functions
exponential_distribution

Exponential Distribution Functions
empirical_cumulative_distribution_function

Empirical Cumulative Distribution Function (ECDF)
error_functions

Error Functions and Inverses
gamma_functions

Gamma Functions
hankel_functions

Hankel Functions
geometric_distribution

Geometric Distribution Functions
binomial_distribution

Binomial Distribution Functions
laguerre_polynomials

Laguerre Polynomials and Related Functions
kolmogorov_smirnov_distribution

Kolmogorov-Smirnov Distribution Functions
inverse_hyperbolic_functions

Inverse Hyperbolic Functions
hyperexponential_distribution

Hyperexponential Distribution Functions
hypergeometric_distribution

Hypergeometric Distribution Functions
double_exponential_quadrature

Double Exponential Quadrature
cubic_hermite

Cubic Hermite Interpolator
lambert_w_function

Lambert W Function and Its Derivatives
landau_distribution

Landau Distribution Functions
inverse_gamma_distribution

Inverse Gamma Distribution Functions
extreme_value_distribution

Extreme Value Distribution Functions
inverse_gaussian_distribution

Inverse Gaussian Distribution Functions
exponential_integrals

Exponential Integrals
inverse_chi_squared_distribution

Inverse Chi-Squared Distribution Functions
hypergeometric_functions

Hypergeometric Functions
negative_binomial_distribution

Negative Binomial Distribution Functions
mapairy_distribution

Map-Airy Distribution Functions
linear_regression

Linear Regression Functions
factorials_and_binomial_coefficients

Factorials and Binomial Coefficients
hermite_polynomials

Hermite Polynomials and Related Functions
holtsmark_distribution

Holtsmark Distribution Functions
filters

Filters
jacobi_polynomials

Jacobi Polynomials and Related Functions
jacobi_elliptic_functions

Jacobi Elliptic Functions
number_series

Number Series
normal_distribution

Normal Distribution Functions
logistic_functions

Logistic Functions
ooura_fourier_integrals

Ooura Fourier Integrals
logistic_distribution

Logistic Distribution Functions
ljung_box_test

Ljung-Box Test for Autocorrelation
owens_t

Owens T Function
pareto_distribution

Pareto Distribution Functions
pchip

PCHIP Interpolator
jacobi_theta_functions

Jacobi Theta Functions
numerical_integration

Numerical Integration
quintic_hermite

Quintic Hermite Interpolator
numerical_differentiation

Numerical Differentiation
lognormal_distribution

Log Normal Distribution Functions
rayleigh_distribution

Rayleigh Distribution Functions
makima

Modified Akima Interpolator
laplace_distribution

Laplace Distribution Functions
poisson_distribution

Poisson Distribution Functions
legendre_polynomials

Legendre Polynomials and Related Functions
runs_tests

Runs Tests
non_central_chi_squared_distribution

Noncentral Chi-Squared Distribution Functions
non_central_beta_distribution

Noncentral Beta Distribution Functions
spherical_harmonics

Spherical Harmonics
rootfinding_and_minimisation

Root-Finding and Minimisation Functions
uniform_distribution

Uniform Distribution Functions
univariate_statistics

Univariate Statistics Functions
polynomial_root_finding

Polynomial Root-Finding
students_t_distribution

Student's T Distribution Functions
vector_functionals

Vector Functionals
sinus_cardinal_hyperbolic_functions

Sinus Cardinal and Hyperbolic Functions
skew_normal_distribution

Skew Normal Distribution Functions
z_tests

Z-Tests
zeta

Riemann Zeta Function
non_central_f_distribution

Noncentral F Distribution Functions
weibull_distribution

Weibull Distribution Functions
saspoint5_distribution

S\(\alpha\)S Point5 Distribution Functions
signal_statistics

Signal Statistics Functions
non_central_t_distribution

Noncentral T Distribution Functions
triangular_distribution

Triangular Distribution Functions
t_tests

T-Tests
arcsine_distribution

Arcsine Distribution Functions
bezier_polynomial

Bezier Polynomial Interpolator
barycentric_rational

Barycentric Rational Interpolation
bernoulli_distribution

Bernoulli Distribution Functions
anderson_darling_test

Anderson-Darling Test for Normality
basic_functions

Basic Mathematical Functions
beta_distribution

Beta Distribution Functions
airy_functions

Airy Functions
bessel_functions

Bessel Functions, Their Derivatives, and Zeros
beta_functions

Beta Functions
bilinear_uniform

Bilinear Uniform Interpolator
boostmath-package

boostmath: 'R' Bindings for the 'Boost' Math Functions
bivariate_statistics

Bivariate Statistics Functions
cardinal_quadratic_b_spline

Cardinal Quadratic B-Spline Interpolator
cardinal_cubic_b_spline

Cardinal Cubic B-Spline Interpolator
cardinal_cubic_hermite

Cardinal Cubic Hermite Interpolator
chatterjee_correlation

Chatterjee Correlation Function
cauchy_distribution

Cauchy Distribution Functions
elliptic_integrals

Elliptic Integrals