Skip to content

Commit f4df375

Browse files
committed
More doc
1 parent 6680865 commit f4df375

29 files changed

Lines changed: 438 additions & 51 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: boostmath
22
Title: 'R' Bindings for the 'Boost' Math Functions
3-
Version: 1.4.0
3+
Version: 1.4.0.9000
44
Authors@R:
55
person(c("Andrew", "R."), "Johnson", , "andrew.johnson@arjohnsonau.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-7000-8065"))

R/basic_functions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
#' @return A single numeric value with the computed result of the function.
3737
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/powers.html) for more details on the mathematical background.
3838
#' @examples
39-
#' # sin(π/2) = 1 (exact)
39+
#' # sin(pi/2) = 1 (exact)
4040
#' sin_pi(0.5)
41-
#' # cos(π/2) = 0 (exact)
41+
#' # cos(pi/2) = 0 (exact)
4242
#' cos_pi(0.5)
4343
#' # log(1 + x) for small x
4444
#' log1p_boost(0.001)

R/bernoulli_distribution.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#' \deqn{F(0)=1-p, \quad F(1)=1}
1212
#'
1313
#' @param x Quantile value (must be 0 or 1).
14-
#' @param p_success Probability of success (0 p_success 1).
15-
#' @param p Probability (0 p 1).
14+
#' @param p_success Probability of success (0 <= p_success <= 1).
15+
#' @param p Probability (0 <= p <= 1).
1616
#' @return A single numeric value with the computed probability density, log-probability density, cumulative distribution, log-cumulative distribution, or quantile depending on the function called.
1717
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/dist_ref/dists/bernoulli_dist.html) for more details on the mathematical background.
1818
#' @examples

R/bessel_functions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' \deqn{J_v(x) = \left(\frac{1}{2}x\right)^v\sum_{k=0}^\infty{\frac{\left(-\frac{1}{4}x^2\right)^k}{k!\Gamma(v+k+1)}}}
1616
#'
17-
#' * `cyl_neumann(v, x)`: Computes the Bessel function of the second kind \eqn{Y_v(x) = N_V(x)}:
17+
#' * `cyl_neumann(v, x)`: Computes the Bessel function of the second kind \eqn{Y_v(x) = N_v(x)}:
1818
#'
1919
#' \deqn{Y_v(x) = \frac{J_v(x)\cos(v\pi) - J_{-v}(x)}{\sin(v\pi)}}
2020
#'

R/beta_distribution.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#'
2626
#' Where \eqn{I_{p}^{-1}} is the inverse of the regularized incomplete beta function.
2727
#'
28-
#' @param x Quantile value (0 x 1).
28+
#' @param x Quantile value (0 <= x <= 1).
2929
#' @param alpha Shape parameter (alpha > 0).
3030
#' @param beta Shape parameter (beta > 0).
31-
#' @param p Probability (0 p 1).
31+
#' @param p Probability (0 <= p <= 1).
3232
#' @param mean Mean of the Beta distribution.
3333
#' @param variance Variance of the Beta distribution.
3434
#' @return A single numeric value with the computed probability density, log-probability density, cumulative distribution, log-cumulative distribution, or quantile depending on the function called.

R/beta_functions.R

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,82 @@
11
#' @title Beta Functions
22
#' @name beta_functions
3-
#' @description Functions to compute the Euler beta function, normalised incomplete beta function, and their complements, as well as their inverses and derivatives.
4-
#' @param a First parameter of the beta function
5-
#' @param b Second parameter of the beta function
3+
#' @description
4+
#' Functions to compute the Beta function, normalized incomplete beta function,
5+
#' and their complements, as well as their inverses and derivatives.
6+
#'
7+
#' **Beta Function \eqn{B(a, b)}:**
8+
#'
9+
#' * `beta_boost(a, b)`
10+
#'
11+
#' \deqn{B(a, b) = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}}
12+
#'
13+
#'
14+
#' **Incomplete Beta Functions:**
15+
#'
16+
#' * **Normalized (Regularized) Functions:**
17+
#' - `ibeta(a, b, x)`: Normalized incomplete beta function \eqn{I_x(a, b)}
18+
#'
19+
#' \deqn{I_x(a,b) = \frac{1}{B(a, b)}\int_{0}^{x}t^{a-1}(1-t)^{b-1}dt}
20+
#'
21+
#' - `ibetac(a, b, x)`: Normalized complement, \eqn{1 - I_x(a, b) = I_{1-x}(b, a)}
22+
#'
23+
#' * **Non-normalized Functions:**
24+
#' - `beta_boost(a, b, x)`: Full incomplete beta function \eqn{B_x(a, b)}
25+
#'
26+
#' \deqn{\int_{0}^{x}t^{a-1}(1-t)^{b-1}dt}
27+
#'
28+
#' - `betac(a, b, x)`: Full complement , \eqn{1 - B_x(a, b) = B_{1-x}(b, a)}
29+
#'
30+
#'
31+
#' **Inverse Functions:**
32+
#'
33+
#' * **Primary inverses (solving for x):**
34+
#' - `ibeta_inv(a, b, p)`: Returns \eqn{x} such that \eqn{p = I_x(a, b)}
35+
#' - `ibetac_inv(a, b, q)`: Returns \eqn{x} such that \eqn{q = 1 - I_x(a, b)}
36+
#'
37+
#' * **Parameter inverses (solving for a or b):**
38+
#' - `ibeta_inva(b, x, p)`: Returns a such that \eqn{p} = I_x(a, b)
39+
#' - `ibetac_inva(b, x, q)`: Returns a such that \eqn{q} = 1 - I_x(a, b)
40+
#' - `ibeta_invb(a, x, p)`: Returns b such that \eqn{p} = I_x(a, b)
41+
#' - `ibetac_invb(a, x, q)`: Returns b such that \eqn{q} = 1 - I_x(a, b)
42+
#'
43+
#' **Derivatives:**
44+
#'
45+
#' `ibeta_derivative(a, b, x)`: Computes the partial derivative with respect to x
46+
#' of the incomplete beta function
47+
#'
48+
#' \deqn{\frac{\partial}{\partial x}I_x(a,b) = \frac{(1-x)^{b-1}x^{a-1}}{B(a,b)}}
49+
#'
50+
#' @param a First parameter of the beta function (must be positive)
51+
#' @param b Second parameter of the beta function (must be positive)
652
#' @param x Upper limit of integration (0 <= x <= 1)
753
#' @param p Probability value (0 <= p <= 1)
8-
#' @param q Probability value (0 <= q <= 1)
9-
#' @return A single numeric value with the computed beta function, normalised incomplete beta function, or their complements, depending on the function called.
54+
#' @param q Probability value (0 <= q <= 1), where q = 1 - p
55+
#' @return A single numeric value with the computed beta function, normalized incomplete beta function, or their complements, depending on the function called.
1056
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/sf_beta.html) for more details on the mathematical background.
1157
#' @examples
1258
#' \dontrun{
1359
#' # Euler beta function B(2, 3)
1460
#' beta_boost(2, 3)
15-
#' # Normalised incomplete beta function I_x(2, 3) for x = 0.5
61+
#' # Normalized incomplete beta function I_x(2, 3) for x = 0.5
1662
#' ibeta(2, 3, 0.5)
17-
#' # Normalised complement of the incomplete beta function 1 - I_x(2, 3) for x = 0.5
63+
#' # Normalized complement of the incomplete beta function 1 - I_x(2, 3) for x = 0.5
1864
#' ibetac(2, 3, 0.5)
1965
#' # Full incomplete beta function B_x(2, 3) for x = 0.5
2066
#' beta_boost(2, 3, 0.5)
2167
#' # Full complement of the incomplete beta function 1 - B_x(2, 3) for x = 0.5
2268
#' betac(2, 3, 0.5)
23-
#' # Inverse of the normalised incomplete beta function I_x(2, 3) = 0.5
69+
#' # Inverse of the normalized incomplete beta function I_x(2, 3) = 0.5
2470
#' ibeta_inv(2, 3, 0.5)
25-
#' # Inverse of the normalised complement of the incomplete beta function I_x(2, 3) = 0.5
71+
#' # Inverse of the normalized complement of the incomplete beta function I_x(2, 3) = 0.5
2672
#' ibetac_inv(2, 3, 0.5)
27-
#' # Inverse of the normalised complement of the incomplete beta function I_x(a, b)
73+
#' # Inverse of the normalized complement of the incomplete beta function I_x(a, b)
2874
#' # with respect to a for x = 0.5 and q = 0.5
2975
#' ibetac_inva(3, 0.5, 0.5)
30-
#' # Inverse of the normalised incomplete beta function I_x(a, b)
76+
#' # Inverse of the normalized incomplete beta function I_x(a, b)
3177
#' # with respect to b for x = 0.5 and p = 0.5
3278
#' ibeta_invb(0.8, 0.5, 0.5)
33-
#' # Inverse of the normalised complement of the incomplete beta function I_x(a, b)
79+
#' # Inverse of the normalized complement of the incomplete beta function I_x(a, b)
3480
#' # with respect to b for x = 0.5 and q = 0.5
3581
#' ibetac_invb(2, 0.5, 0.5)
3682
#' # Derivative of the incomplete beta function with respect to x for a = 2, b = 3, x = 0.5

R/binomial_distribution.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#' @title Binomial Distribution Functions
22
#' @name binomial_distribution
3-
#' @description Functions to compute the probability density function, cumulative distribution function, and quantile function for the Binomial distribution.
3+
#' @description Functions to compute the probability density function, cumulative distribution function,
4+
#' and quantile function for the Binomial distribution.
5+
#'
6+
#' The PDF is:
7+
#'
8+
#' \deqn{f(k; n, p) = \frac{n!}{k!(n-k)!}p^k(1-p)^{n-k}}
9+
#'
10+
#' The CDF is:
11+
#'
12+
#' \deqn{1 - I_p(k + 1, n - k)}
13+
#'
414
#' @param k number of successes (0 <= k <= n)
515
#' @param n number of trials (n >= 0)
616
#' @param prob probability of success on each trial (0 <= prob <= 1)

R/bivariate_statistics.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#' @title Bivariate Statistics Functions
22
#' @name bivariate_statistics
33
#' @description Functions to compute various bivariate statistics.
4+
#'
5+
#' * `covariance(x, y)`: Compute population covariance of `x` & `y`
6+
#' * `means_and_covariance(x, y)`: Boost estimates the means as part of the covariance estimation,
7+
#' return them in a single pass
8+
#' * `correlation_coefficient(x, y)`: Perason correlation coefficient of `x` & `y`
9+
#'
10+
#'
11+
#'
412
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/bivariate_statistics.html) for more details on the mathematical background.
513
#' @param x A numeric vector.
614
#' @param y A numeric vector.

R/cauchy_distribution.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#' @title Cauchy Distribution Functions
22
#' @name cauchy_distribution
3-
#' @description Functions to compute the probability density function, cumulative distribution function, and quantile function for the Cauchy distribution.
3+
#' @description Functions to compute the probability density function, cumulative distribution function,
4+
#' and quantile function for the Cauchy distribution.
5+
#'
6+
#' The PDF is:
7+
#'
8+
#' \deqn{f(x; x_0, \gamma) = \frac{1}{\pi}\left(\frac{\gamma}{(x-x_0)^2 + \gamma^2}\right)}
9+
#'
10+
#' The CDF:
11+
#'
12+
#' \deqn{F(x; x_0, \gamma) = \frac{1}{\pi}\text{arctan}\left(\frac{x-x_0}{\gamma}\right)+\frac{1}{2}}
13+
#'
414
#' @param x quantile
515
#' @param location location parameter (default is 0)
616
#' @param scale scale parameter (default is 1)

R/chatterjee_correlation.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#' @title Chatterjee Correlation Function
22
#' @name chatterjee_correlation
3-
#' @description Functions to compute the Chatterjee correlation.
3+
#' @description Compute the Chatterjee correlation coefficient, a rank-based coefficient:
4+
#'
5+
#' \deqn{\xi_n(X,Y) = 1 - \frac{3\sum_{i=1}^{n-1}|r_{i+1} - r_i|}{n^2 - 1}}
6+
#'
47
#' @seealso [Boost Documentation](https://www.boost.org/doc/libs/latest/libs/math/doc/html/math_toolkit/chatterjee_correlation.html) for more details on the mathematical background.
58
#' @param x A numeric vector.
69
#' @param y A numeric vector.

0 commit comments

Comments
 (0)