The goal of bradfordr is to implement probability functions from the Standardized Bradford Distribution in the same way other distributions are implemented in the {stats}
package. Its definition and functionality were taken from SciPy.
A continuous random variable follows the Standardized Bradford Distribution if it’s probability density function is given as the following:
For 0 <= x <= 1 and c > 0.
It comes primarily from Bradford’s law of scattering, which states that, if journals in a specific field are sorted into three groups (each with one third of all articles of that field), the number of journals in each group will be proportional to 1 : n : n2. The Bradford Distribution itself is a special case of the Pareto Distribution, and has some relations with the Exponential Distribution.
You can install the development version of bradfordr from GitHub with:
# install.packages("devtools")
devtools::install_github("victordogo/bradfordr")
bradfordr contains 4 basic functions, exemplified below. More in depth applications can be seen in the vignettes of this package.
The rbradford
function generates a vector of values from the Standardized Bradford Distribution with length n
and parameter c
using the Inverse Transform Sampling Method.
The standard value for c
is 5:
library(bradfordr)
rbradford(n=10)
#> [1] 0.185216959 0.100725128 0.931113765 0.184023942 0.003606418 0.637271882
#> [7] 0.031869913 0.581854982 0.743135455 0.274802504
If the value of c is less or equal than 0, the function returns an error (this is true to all functions in this package).
The pbradford
function returns the probabilities calculated from the accumulated distribution function of the Standardized Bradford Distribution:
If lower.tail=FALSE
, however, it returns 1 − F(x; c). It also has the option to return probabilities in the logarithmic scale.
The dbradford
function gives the distribution’s pdf. By definition, we can’t really calculate probabilities like we do with discrete distributions (think like P(X = 10)), so this is the least useful function in the package.
The qbradford
function gives the distribution’s quantile function. It’s useful for discovering what value would satisfy P(X ≤ x) = p. The same arguments from pbradford
apply here.
# What value of x satisfies P(X <= x) = 0.8 when c=100?
qbradford(p=0.8, c=100)
#> [1] 0.3912889
“I am Wan Shi Tong, he who knows ten thousand things, and you are obviously humans; which, by the way, are no longer permitted in my study.”
Wan Shi Tong is a wise spirit from the popular acclaimed series “Avatar: The Last Airbender” and its sequel, “Avatar: The Legend of Korra”. In both series, its task is to guard and mantain the Spirit Library, in which almost all knowledge of the world is kept shut from dangerous and unwanted guests.
Because the Bradford Distribution comes from a law that describes, in a kind of stretch, knowledge and its distribution, I figured that it would be nice to reference a series I love.