| Title: | Fitting of Univariate Mixture Distributions to Data using Various Approaches |
|---|---|
| Description: | Methods for fitting mixture distributions to univariate data using expectation maximization, HWHM and other methods. Supports Gaussian, Cauchy, Student's t, skew-normal and von Mises mixtures. For more details see Merkys (2018) <https://www.lvb.lt/permalink/370LABT_NETWORK/1m6ui06/alma9910036312108451>. |
| Authors: | Andrius Merkys [aut, cre] |
| Maintainer: | Andrius Merkys <[email protected]> |
| License: | GPL-2 |
| Version: | 0.8.0 |
| Built: | 2026-05-28 14:48:06 UTC |
| Source: | https://github.com/merkys/mixturefitting |
Compare two values to tell whether an optimization process has converged.
abs_convergence( p_now, p_prev, epsilon = 1e-6 )abs_convergence( p_now, p_prev, epsilon = 1e-6 )
p_now |
function value of i-th iteration. |
p_prev |
function value of i-1-th iteration. |
epsilon |
convergence criterion |
TRUE if deemed to have converged, FALSE otherwise
Andrius Merkys
Calculates Bayesian Information Criterion (AIC) for any type of mixture model. Log-likelihood function has to be provided.
aic( x, p, llf )aic( x, p, llf )
x |
data vector |
p |
vector of mixture model parameters |
llf |
function calculating log-likelihood, called as llf( x, p ) |
Akaike Information Criterion value.
Andrius Merkys
Measures Bhattacharyya distance for two univariate Gaussian distributions.
bhattacharyya_dist( mu1, mu2, sigma1, sigma2 )bhattacharyya_dist( mu1, mu2, sigma1, sigma2 )
mu1 |
mean of the first Gaussian distribution. |
mu2 |
mean of the second Gaussian distribution. |
sigma1 |
standard deviation of the first Gaussian distribution. |
sigma2 |
standard deviation of the second Gaussian distribution. |
Bhattacharyya distance as double.
Andrius Merkys
Calculates Bayesian Information Criterion (BIC) for any type of mixture model. Log-likelihood function has to be provided.
bic( x, p, llf )bic( x, p, llf )
x |
data vector |
p |
vector of mixture model parameters |
llf |
function calculating log-likelihood, called as llf( x, p ) |
Bayesian Information Criterion value.
Andrius Merkys
Estimates parameters for Caucy mixture using Expectation Maximization algorithm.
cmm_fit_em( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), iter.cauchy = 20, debug = FALSE, implementation = "C" )cmm_fit_em( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), iter.cauchy = 20, debug = FALSE, implementation = "C" )
x |
data vector |
p |
initialization vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the center of i-th component and gammai is the Cauchy scale of i-th component. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_gamma ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers and epsilon_gamma is threshold for component Cauchy scales. |
iter.cauchy |
number of iterations to fit a single Cauchy component. |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Ferenc Nahy. Parameter Estimation of the Cauchy Distribution in Information Theory Approach (2006). Journal of Universal Computer Science
Estimate Cauchy mixture parameters using derivatives and half-width at half-maximum (HWHM) method. The method smooths the histogram before attempting to locate the modes. Then it describes them using HWHM.
cmm_fit_hwhm_spline_deriv( x, y )cmm_fit_hwhm_spline_deriv( x, y )
x |
data vector |
y |
response vector for x |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the center of i-th component and gammai is the Cauchy scale of i-th component.
Andrius Merkys
Estimate an initialization vector for Cauchy mixture fitting via Expectation Maximization. Proportions are set to equal, centers are equispaced through the whole domain of input sample, and scales are set to 1.
cmm_init_vector( x, m, implementation = "C" )cmm_init_vector( x, m, implementation = "C" )
x |
data vector |
m |
number of mixture components |
implementation |
flag to switch between C (default) and R implementations. |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the center of i-th component and gammai is the Cauchy scale of i-th component.
Andrius Merkys
Estimate an initialization vector for Cauchy mixture fitting using k-means. R implementation of k-means in kmeans() is used to find data point assignment to clusters. Then several iterations of Cauchy mixture fitting (per Nahy 2006) is used to derive mixture parameters.
cmm_init_vector_kmeans( x, m, iter.cauchy = 20 )cmm_init_vector_kmeans( x, m, iter.cauchy = 20 )
x |
data vector |
m |
number of mixture components |
iter.cauchy |
number of iterations to fit a single Cauchy component. |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the center of i-th component and gammai is the Cauchy scale of i-th component.
Andrius Merkys
Ferenc Nahy. Parameter Estimation of the Cauchy Distribution in Information Theory Approach (2006). Journal of Universal Computer Science
Finds intersections of two Cauchy distributions by finding roots of a quadratic equation.
cmm_intersections( p )cmm_intersections( p )
p |
parameter vector of 6 parameters. Structure of p vector is p = c( A1, A2, mu1, mu2, gamma1, gamma2 ), where Ai is the proportion of i-th component, mui is the location of i-th component, gammai is the Cauchy scale of i-th component. |
A vector of x values of intersections (zero, one or two). Returns NaN if both distributions are identical.
Andrius Merkys
Density function for the Cauchy-Gaussian distribution, according to Eqn. 2 of Swami (2000).
dcgmm( x, p )dcgmm( x, p )
x |
data vector |
p |
parameter vector of 5*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, e1, e2, ..., en, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, ei is the proportion of Cauchy subcomponent of i-th component, mui is the center of i-th component, gammai is the Cauchy concentration of i-th component and sigmai is the Gaussian standard deviation of i-th component. |
A vector.
Andrius Merkys
Swami, A. Non-Gaussian mixture models for detection and estimation in heavy-tailed noise 2000 IEEE International Conference on Acoustics, Speech, and Signal Processing. Proceedings (Cat. No.00CH37100), 2000, 6, 3802-3805
Density function for the Cauchy mixture distribution.
dcmm( x, p, implementation = "C" )dcmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the location of i-th component, gammai is the Cauchy scale of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
A vector.
Andrius Merkys
Density function for the Gaussian mixture distribution.
dgmm( x, p, normalise_proportions = FALSE, restrict_sigmas = FALSE, implementation = "C" )dgmm( x, p, normalise_proportions = FALSE, restrict_sigmas = FALSE, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
normalise_proportions |
if TRUE, make component proportions sum up to 1 by dividing each one of them by their sum (R implementation only). |
restrict_sigmas |
if TRUE, skip components with scales less or equal to zero (R implementation only). |
implementation |
flag to switch between C (default) and R implementations. |
A vector.
Andrius Merkys
Calculates approximate value of the digamma function using first eight non-zero members of asymptotic expression for digamma(x). Implemented according to Wikipedia.
digamma_approx( x )digamma_approx( x )
x |
data vector |
Digamma function value.
Andrius Merkys
Users of Wikipedia. Digamma function. https://en.wikipedia.org/w/index.php?title=Digamma_function&oldid=708779689
Density function for the Student's t Model. Wrapper around R's dt(), supporting center and concentration parameters.
ds( x, c, s, ni )ds( x, c, s, ni )
x |
data vector |
c |
center |
s |
concentration |
ni |
degrees of freedom |
A vector.
Andrius Merkys
Density function for the Student's t Mixture Model.
dsmm( x, p )dsmm( x, p )
x |
data vector |
p |
parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
A vector.
Andrius Merkys
Density function for the skew-normal mixture model.
dsnmm( x, p, implementation = "C" )dsnmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( omega1, omega2, ..., omegan, dzeta1, dzeta2, ..., dzetan, sigma1, sigma2, ..., sigman, lambda1, lambda2, ..., lambdan ), where omegai is the proportion of i-th component, dzetai is the location of i-th component, sigmai is the scale of i-th component and lambdai is the shape of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
A vector.
Andrius Merkys
Density function for the von Mises Mixture Model.
dvmm( x, p, implementation = "C" )dvmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
A vector.
Andrius Merkys
Estimates parameters for Gaussian mixture using Expectation Maximization algorithm.
gmm_fit_em( x, p, w = numeric(), epsilon = c( 0.000001, 0.000001, 0.000001 ), max_steps = 0, debug = FALSE, implementation = "C", ... )gmm_fit_em( x, p, w = numeric(), epsilon = c( 0.000001, 0.000001, 0.000001 ), max_steps = 0, debug = FALSE, implementation = "C", ... )
x |
data vector |
p |
initialization vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the center of i-th component and sigmai is the scale of i-th component. |
w |
weights of data points, must have the same length as the data vector; if not given or has different length, equal weights are assumed. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_sigma ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers and epsilon_sigma is threshold for component scales. |
max_steps |
maximum number of steps (0 = no limit). |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
... |
additional arguments passed to gmm_fit_em_R() when R implementation is used. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Estimate Gaussian mixture parameters using half-width at half-maximum (HWHM) method. Given a histogram, the method attempts to locate most prominent modes and describe them using HWHM.
gmm_fit_hwhm( x, y, n )gmm_fit_hwhm( x, y, n )
x |
data vector |
y |
response vector for x |
n |
number of mixture components |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Estimate Gaussian mixture parameters using derivatives and half-width at half-maximum (HWHM) method. The method smooths the histogram before attempting to locate the modes. Then it describes them using HWHM.
gmm_fit_hwhm_spline_deriv( x, y )gmm_fit_hwhm_spline_deriv( x, y )
x |
data vector |
y |
response vector for x |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Estimates parameters for Gaussian mixture using kmeans.
gmm_fit_kmeans( x, n )gmm_fit_kmeans( x, n )
x |
data vector |
n |
number of mixture components |
Vector of 3*n mixture parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Estimate an initialization vector for Gaussian mixture fitting via Expectation Maximization. Proportions and scales are set to equal, centers are equispaced through the whole domain of input sample.
gmm_init_vector( x, n, implementation = "C" )gmm_init_vector( x, n, implementation = "C" )
x |
data vector |
n |
number of mixture components |
implementation |
flag to switch between C (default) and R implementations. |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Estimate an initialization vector for Gaussian mixture fitting using k-means. R implementation of k-means in kmeans() is used to find data point assignment to clusters.
gmm_init_vector_kmeans( x, m )gmm_init_vector_kmeans( x, m )
x |
data vector |
m |
number of mixture components |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Estimate an initialization vector for Gaussian mixture fitting using (weighted) quantiles. Proportions and scales are set to equal, centers are placed at equispaced quantiles.
gmm_init_vector_quantile( x, m, w = numeric() )gmm_init_vector_quantile( x, m, w = numeric() )
x |
data vector |
m |
number of mixture components |
w |
weight vector |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Finds intersections of two Gaussian distributions by finding roots of a quadratic equation.
gmm_intersections( p )gmm_intersections( p )
p |
parameter vector of 6 parameters. Structure of p vector is p = c( A1, A2, mu1, mu2, sigma1, sigma2 ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
A vector of x values of intersections (zero, one or two). Returns NaN if both distributions are identical.
Andrius Merkys
Merges ith and jth components of Gaussian mixture
model. Implemented in the same venue as in
mergeparameters of fpc.
gmm_merge_components( x, p, i, j )gmm_merge_components( x, p, i, j )
x |
data vector |
p |
vector of Gaussian mixture parameters. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where n is number of mixture components, Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component. |
i |
index of the first component to be merged. Component with this index will be replaced by a merged one in the output. |
j |
index of the second component to be merged. Component with this index will be removed in the output. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Hennig, C. Methods for merging Gaussian mixture components Advances in Data Analysis and Classification, Springer Nature, 2010, 4, 3-34
Calculates the posterior probability of a Gaussian mixture with n components. Internally, it attempts to maximize log-likelihood of data by calling optim() and returns the list as received from optim().
gmm_size_probability( x, n, method = "SANN" )gmm_size_probability( x, n, method = "SANN" )
x |
data vector |
n |
number of mixture components |
method |
optimization method passed to optim() |
List representing the converged optim() run.
Andrius Merkys
Calculates the posterior probability of a Gaussian mixture with n components. Internally, it bins the data vector and calls nls() to optimize the mixture fit. Returns the list of the same form as received from optim().
gmm_size_probability_nls( x, n, bins = 100, trace = FALSE )gmm_size_probability_nls( x, n, bins = 100, trace = FALSE )
x |
data vector |
n |
number of mixture components |
bins |
number of bins |
trace |
should debug trace be printed? |
List of the same form as received from optim().
Andrius Merkys
Simple implementation of gradient descent method. Given a derivative function, it follows its decrease until convergence criterion is met.
gradient_descent( gradfn, start, gamma = 0.1, ..., epsilon = 0.01 )gradient_descent( gradfn, start, gamma = 0.1, ..., epsilon = 0.01 )
gradfn |
derivative function |
start |
starting value |
gamma |
learning rate |
... |
additional arguments passed to derivative function |
epsilon |
convergence threshold for absolute squared difference |
log-likelihood
Andrius Merkys
Measures Kullback–Leibler divergence of ith Student's t Mixture component using Dirac's delta function. Implemented according to Chen et al. (2004).
kldiv( x, p, k )kldiv( x, p, k )
x |
data vector |
p |
vector of Student's t mixture parameters. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where n is number of mixture components, Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
k |
number of the component. |
Kullback–Leibler divergence as double.
Andrius Merkys
Chen, S.; Wang, H. & Luo, B. Greedy EM Algorithm for Robust T-Mixture Modeling Third International Conference on Image and Graphics (ICIG'04), Institute of Electrical & Electronics Engineers (IEEE), 2004, 548–551
Perform k-means clustering on angular data (in degrees).
kmeans_circular( x, centers, iter.max = 10 )kmeans_circular( x, centers, iter.max = 10 )
x |
data vector |
centers |
vector of initial centers (in degrees) |
iter.max |
maximum number of iterations |
Vector of the same length as centers defining cluster centers (in degrees).
Andrius Merkys
Calculates log-likelihood for a given data vector using a Cauchy mixture distribution.
llcmm( x, p, implementation = "C" )llcmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the center of i-th component and gammai is the Cauchy scale of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
log-likelihood
Andrius Merkys
Calculates log-likelihood for a given data vector using a Gaussian mixture distribution.
llgmm( x, p, implementation = "C" )llgmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the center of i-th component and sigmai is the scale of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
log-likelihood
Andrius Merkys
Calculates log-likelihood for a given data vector using a Gaussian mixture distribution. This is a straightforward implementation, different from llgmm() in that that it does not detect and shortcut edge cases.
llgmm_conservative( x, p )llgmm_conservative( x, p )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the center of i-th component and sigmai is the scale of i-th component. |
log-likelihood
Andrius Merkys
Calculates opposite log-likelihood for a given data vector using a Gaussian mixture distribution.
llgmm_opposite( x, p )llgmm_opposite( x, p )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the center of i-th component and sigmai is the scale of i-th component. |
opposite log-likelihood (negated log-likelihood value)
Andrius Merkys
Calculates log-likelihood for a given data vector using a Student's t mixture distribution.
llsmm( x, p )llsmm( x, p )
x |
data vector |
p |
parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
log-likelihood
Andrius Merkys
Calculates log-likelihood for a given data vector using a skew-normal mixture distribution.
llsnmm( x, p )llsnmm( x, p )
x |
data vector |
p |
parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( omega1, omega2, ..., omegan, dzeta1, dzeta2, ..., dzetan, sigma1, sigma2, ..., sigman, lambda1, lambda2, ..., lambdan ), where omegai is the proportion of i-th component, dzetai is the location of i-th component, sigmai is the scale of i-th component and lambdai is the shape of i-th component. |
log-likelihood
Andrius Merkys
Calculates log-likelihood for a given data vector using a von Mises mixture distribution.
llvmm( x, p, implementation = "C" )llvmm( x, p, implementation = "C" )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
implementation |
flag to switch between C (default) and R implementations. |
log-likelihood
Andrius Merkys
Calculates opposite log-likelihood for a given data vector using a von Mises mixture distribution.
llvmm_opposite( x, p )llvmm_opposite( x, p )
x |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
opposite log-likelihood (negated log-likelihood value)
Andrius Merkys
Draw a PNG histogram with a mixture density on top of it for each iteration of mixture optimization process.
mk_fit_images( h, l, prefix = "img_" )mk_fit_images( h, l, prefix = "img_" )
h |
histogram object, as returned from hist() |
l |
list containing model vectors |
prefix |
prefix of file name to write |
Andrius Merkys
Plot a circular histogram.
plot_circular_hist( x, breaks = 72, ball = 0.5, ... )plot_circular_hist( x, breaks = 72, ball = 0.5, ... )
x |
data vector |
breaks |
number of breaks in histogram |
ball |
radius of the drawn circle |
... |
parameters passed to plot() |
Andrius Merkys
Draw a PNG histogram with a mixture density on top of it.
plot_density( x, model, density_f, width, height, cuts = 400, main = "", filename = NULL, obs_good = c(), obs_bad = c(), scale_density = FALSE )plot_density( x, model, density_f, width, height, cuts = 400, main = "", filename = NULL, obs_good = c(), obs_bad = c(), scale_density = FALSE )
x |
data vector |
cuts |
number of breaks in histogram |
main |
main title of the plot |
model |
model passed to density_f() |
density_f |
probability density function |
filename |
name of the file to write |
width |
image width, passed to png() |
height |
image height, passed to png() |
obs_good |
vector of values to mark with rug() in green color |
obs_bad |
vector of values to mark with rug() in red color |
scale_density |
should probability density be scaled? |
Andrius Merkys
Finds one real polynomial root using Newton–Raphson method, implemented according to Wikipedia.
polyroot_NR( p, init = 0, epsilon = 1e-6, debug = FALSE, implementation = "C" )polyroot_NR( p, init = 0, epsilon = 1e-6, debug = FALSE, implementation = "C" )
p |
vector of polynomial coefficients. |
init |
initial value. |
epsilon |
tolerance threshold for convergence. |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Real polynomial root.
Andrius Merkys
Users of Wikipedia. Newton's method. https://en.wikipedia.org/w/index.php?title=Newton%27s_method&oldid=710342140
Given two vectors of same length and a Gaussian mixture, calculate the penalized sum of squared differences (SSD) between the first vector and Gaussian mixture densities measured at points from second vector. Penalties are included for proportions and scales that are less than or equal to 0.
pssd( x, y, p )pssd( x, y, p )
x |
data vector |
y |
response vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
Penalized sum of squared differences.
Andrius Merkys
Gradient (derivative) function of pssd().
pssd_gradient( x, y, p )pssd_gradient( x, y, p )
x |
data vector |
y |
response vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
Gradient values measured at x.
Andrius Merkys
Compare two values to tell whether an optimization process has converged. The absolute difference between values of two iterations is divided by the value of previous iteration and compared to the epsilon value.
ratio_convergence( p_now, p_prev, epsilon = 1e-6 )ratio_convergence( p_now, p_prev, epsilon = 1e-6 )
p_now |
function value of i-th iteration. |
p_prev |
function value of i-1-th iteration. |
epsilon |
convergence criterion |
TRUE if deemed to have converged, FALSE otherwise
Andrius Merkys
Generates a random sample of the Cauchy mixture distribution.
rcmm( n, p )rcmm( n, p )
n |
sample size |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, gamma1, gamma2, ..., gamman ), where Ai is the proportion of i-th component, mui is the location of i-th component, gammai is the Cauchy scale of i-th component. |
A vector.
Andrius Merkys
Generates a random sample of the Gaussian mixture distribution.
rgmm( n, p )rgmm( n, p )
n |
data vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
A vector.
Andrius Merkys
Generate initial simplices for simplex().
rsimplex_start( seed, n, lower, upper )rsimplex_start( seed, n, lower, upper )
seed |
seed for random number generator |
n |
number of simplices |
lower |
vector with lower bounds of each dimension |
upper |
vector with upper bounds of each dimension |
A list with n simplices.
Andrius Merkys
Generates a random sample of the von Mises Mixture Model.
rvmm( n, p )rvmm( n, p )
n |
sample size |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
A vector.
Andrius Merkys
Best & Fisher. Efficient Simulation of the von Mises Distribution. Journal of the RSS, Series C, 1979, 28, 152-157.
Estimates parameters for univariate Student's t distribution parameters using Batch Approximation Algorithm, according to Fig. 2 of Aeschliman et al. (2010).
s_fit_primitive( x )s_fit_primitive( x )
x |
data vector |
Vector c( mu, k, ni ), where
mu is the center,
k is the concentration and
ni is the degrees of freedom of the distribution.
Andrius Merkys
Aeschliman, C.; Park, J. & Kak, A. C. A Novel Parameter Estimation Algorithm for the Multivariate t-Distribution and Its Application to Computer Vision European Conference on Computer Vision 2010, 2010 https://engineering.purdue.edu/RVL/Publications/Aeschliman2010ANovel.pdf
Nelder-Mead's Simplex Method for Function Minimization.
simplex( fn, start, ..., epsilon = 0.000001, alpha = 1, gamma = 2, rho = 0.5, delta = 0.5, trace = FALSE )simplex( fn, start, ..., epsilon = 0.000001, alpha = 1, gamma = 2, rho = 0.5, delta = 0.5, trace = FALSE )
fn |
minimized function, has to accept the argmin vector as first parameter |
start |
start vector |
... |
other parameters passed to the minimized function |
epsilon |
convergence criterion |
alpha |
reflection coefficient |
gamma |
expansion coefficient |
rho |
contraction coefficient |
delta |
shrink coefficient |
trace |
should debug trace be printed? |
Vector yielding the minimum value of the minimized function
Andrius Merkys
Nelder, J. A. & Mead, R. A Simplex Method For Function Minimization. The Computer Journal, 1965, 308-313.
Users of Wikipedia. Nelder-Mead method. https://en.wikipedia.org/w/index.php?title=Nelder%E2%80%93Mead_method&oldid=1287347131
Estimates parameters for Student's t mixture using Expectation Maximization algorithm. Calls smm_fit_em_APK10().
smm_fit_em( x, p, ... )smm_fit_em( x, p, ... )
x |
data vector |
p |
initialization vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
... |
additional arguments passed to smm_fit_em_GNL08(). |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Estimates parameters for univariate Student's t mixture using Expectation Maximization algorithm, according to Fig. 2 of Aeschliman et al. (2010).
smm_fit_em_APK10( x, p, epsilon = c( 1e-6, 1e-6, 1e-6, 1e-6 ), collect.history = FALSE, debug = FALSE )smm_fit_em_APK10( x, p, epsilon = c( 1e-6, 1e-6, 1e-6, 1e-6 ), collect.history = FALSE, debug = FALSE )
x |
data vector |
p |
initialization vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_k, epsilon_ni ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers, epsilon_k is threshold for component concentrations and epsilon_ni is threshold for component degrees of freedom. |
collect.history |
flag to turn accumulation of estimation history on/off. |
debug |
flag to turn the debug prints on/off. |
A list.
Andrius Merkys
Aeschliman, C.; Park, J. & Kak, A. C. A Novel Parameter Estimation Algorithm for the Multivariate t-Distribution and Its Application to Computer Vision European Conference on Computer Vision 2010, 2010 https://engineering.purdue.edu/RVL/Publications/Aeschliman2010ANovel.pdf
Estimates (greedily) parameters for univariate Student's t mixture using Expectation Maximization algorithm, implemented according to Chen et al. (2004). The algorithm relies upon smm_fit_em_GNL08() to estimate mixture parameters iteratively.
smm_fit_em_CWL04( x, p, collect.history = FALSE, debug = FALSE, ... )smm_fit_em_CWL04( x, p, collect.history = FALSE, debug = FALSE, ... )
x |
data vector |
p |
initialization vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
collect.history |
logical. If set to TRUE, a list of parameter values of all iterations is returned. |
debug |
flag to turn the debug prints on/off. |
... |
parameters passed to smm_fit_em_GNL08(). |
A list.
Andrius Merkys
Chen, S.; Wang, H. & Luo, B. Greedy EM Algorithm for Robust T-Mixture Modeling Third International Conference on Image and Graphics (ICIG'04), Institute of Electrical & Electronics Engineers (IEEE), 2004, 548–551
Estimates parameters for univariate Student's t mixture using Expectation Maximization algorithm, according to Eqns. 12–17 of Gerogiannis et al. (2009).
smm_fit_em_GNL08( x, p, epsilon = c( 1e-6, 1e-6, 1e-6, 1e-6 ), collect.history = FALSE, debug = FALSE, min.sigma = 1e-256, min.ni = 1e-256, max.df = 1000, max.steps = Inf, polyroot.solution = 'jenkins_taub', convergence = abs_convergence, unif.component = FALSE )smm_fit_em_GNL08( x, p, epsilon = c( 1e-6, 1e-6, 1e-6, 1e-6 ), collect.history = FALSE, debug = FALSE, min.sigma = 1e-256, min.ni = 1e-256, max.df = 1000, max.steps = Inf, polyroot.solution = 'jenkins_taub', convergence = abs_convergence, unif.component = FALSE )
x |
data vector |
p |
initialization vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_k, epsilon_ni ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers, epsilon_k is threshold for component concentrations and epsilon_ni is threshold for component degrees of freedom. |
collect.history |
logical. If set to TRUE, a list of parameter values of all iterations is returned. |
debug |
flag to turn the debug prints on/off. |
min.sigma |
minimum value of sigma |
min.ni |
minimum value of degrees of freedom |
max.df |
maximum value of degrees of freedom |
max.steps |
maximum number of steps, may be infinity |
polyroot.solution |
polyroot finding method used to approximate digamma function. Possible values are 'jenkins_taub' and 'newton_raphson'. |
convergence |
function to use for convergence checking. Must accept function values of the last two iterations and return TRUE or FALSE. |
unif.component |
should a uniform component for outliers be added, as suggested by Cousineau & Chartier (2010)? |
A list.
Andrius Merkys
Gerogiannis, D.; Nikou, C. & Likas, A. The mixtures of Student's t-distributions as a robust framework for rigid registration. Image and Vision Computing, Elsevier BV, 2009, 27, 1285–1294 https://www.cs.uoi.gr/~arly/papers/imavis09.pdf
Cousineau, D. & Chartier, S. Outliers detection and treatment: a review. International Journal of Psychological Research, 2010, 3, 58–67 https://revistas.usb.edu.co/index.php/IJPR/article/view/844
Estimate an initialization vector for Student's t mixture fitting via Expectation Maximization. Proportions are set to be equal, centers are equispaced through the whole domain of input sample, concentrations and degrees of freedom are set to 1.
smm_init_vector( x, n )smm_init_vector( x, n )
x |
data vector |
n |
number of mixture components |
Parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component.
Andrius Merkys
Estimate an initialization vector for Student's t mixture fitting via Expectation Maximization. R implementation of k-means in kmeans() is used to find data point assignment to clusters. s_fit_primitive() is then used to estimate component parameters for each cluster.
smm_init_vector_kmeans( x, m )smm_init_vector_kmeans( x, m )
x |
data vector |
m |
number of mixture components |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component.
Andrius Merkys
Splits a component of Student's t-distribution mixture. Implemented according to Eqns. 30–36 of Chen et al. (2004).
smm_split_component( p, alpha = 0.5, beta = 0.5, u = 0.5 )smm_split_component( p, alpha = 0.5, beta = 0.5, u = 0.5 )
p |
vector of Student's t mixture parameters. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn, ni1, ni2, ..., nin ), where n is number of mixture components, Ai is the proportion of i-th component, mui is the center of i-th component, ki is the concentration of i-th component and nii is the degrees of freedom of i-th component. |
alpha |
split proportion for component proportions |
beta |
split proportion for component concentrations |
u |
split proportion for component centers |
Vector of parameters for resulting two-component mixture, whose structure is the same as of input parameter's p.
Andrius Merkys
Chen, S.-B. & Luo, B. Robust t-mixture modelling with SMEM algorithm Proceedings of 2004 International Conference on Machine Learning and Cybernetics (IEEE Cat. No.04EX826), Institute of Electrical & Electronics Engineers (IEEE), 2004, 6, 3689–3694
Estimates parameters for skew-normal mixture using Expectation Maximization algorithm.
snmm_fit_em( x, p, w = numeric(), epsilon = c( 0.000001, 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )snmm_fit_em( x, p, w = numeric(), epsilon = c( 0.000001, 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )
x |
data vector |
p |
initialization vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( omega1, omega2, ..., omegan, dzeta1, dzeta2, ..., dzetan, sigma1, sigma2, ..., sigman, lambda1, lambda2, ..., lambdan ), where omegai is the proportion of i-th component, dzetai is the location of i-th component, sigmai is the scale of i-th component and lambdai is the shape of i-th component. |
w |
weights of data points, must have the same length as the data vector; if not given or has different length, equal weights are assumed. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_omega, epsilon_dzeta, epsilon_sigma, epsilon_lambda ), where epsilon_omega is threshold for component proportions, epsilon_dzeta is threshold for component locations, epsilon_sigma is threshold for component scales and epsilon_lambda is threshold for component shapes. |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Arnold et al. The nontruncated marginal of a truncated bivariate normal distribution, Psychometrika 58, pages 471–488 (1993)
Lin et al. Finite mixture modelling using the skew normal distribution, Statistica Sinica 17 (2007), 909–927 https://www3.stat.sinica.edu.tw/statistica/oldpdf/A17n35.pdf
Estimate an initialization vector for skew-normal mixture fitting via Expectation Maximization. Estimation method follows Lin et al. (2007) suggestion to use k-means clustering for initial cluster assignment. Calculation of moments and dzeta and sigma parameters are done according to Equation 3 of Lin et al. (2007), but lambda is estimated from Equation 18c of Arnold et al. (1993).
snmm_init_vector( x, n = 1 )snmm_init_vector( x, n = 1 )
x |
data vector |
n |
number of mixture components |
Parameter vector of 4*n parameters, where n is number of mixture components. Structure of p vector is p = c( omega1, omega2, ..., omegan, dzeta1, dzeta2, ..., dzetan, sigma1, sigma2, ..., sigman, lambda1, lambda2, ..., lambdan ), where omegai is the proportion of i-th component, dzetai is the location of i-th component, sigmai is the scale of i-th component and lambdai is the shape of i-th component.
Andrius Merkys
Arnold et al. The nontruncated marginal of a truncated bivariate normal distribution, Psychometrika 58, pages 471–488 (1993)
Lin et al. Finite mixture modelling using the skew normal distribution, Statistica Sinica 17 (2007), 909–927 https://www3.stat.sinica.edu.tw/statistica/oldpdf/A17n35.pdf
Given two vectors of same length and a Gaussian mixture, calculate the sum of squared differences (SSD) between the first vector and Gaussian mixture densities measured at points from second vector.
ssd( x, y, p )ssd( x, y, p )
x |
data vector |
y |
response vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
Sum of squared differences.
Andrius Merkys
Gradient (derivative) function of ssd().
ssd_gradient( x, y, p )ssd_gradient( x, y, p )
x |
data vector |
y |
response vector |
p |
parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, sigma1, sigma2, ..., sigman ), where Ai is the proportion of i-th component, mui is the location of i-th component, sigmai is the scale of i-th component. |
Gradient values measured at x.
Andrius Merkys
Estimates parameters for univariate von Mises mixture using Expectation Maximization algorithm.
vmm_fit_em( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )vmm_fit_em( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )
x |
data vector |
p |
initialization vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_k ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers and epsilon_k is threshold for component concentrations. |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Banerjee et al. Expectation Maximization for Clustering on Hyperspheres (2003), manuscript, accessible on: https://web.archive.org/web/20130120061240/http://www.lans.ece.utexas.edu/~abanerjee/papers/05/banerjee05a.pdf
Estimates parameters for univariate von Mises mixture using Expectation Maximization algorithm. In this version stopping criterion is the difference between parameters in the subsequent iterations.
vmm_fit_em_by_diff( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )vmm_fit_em_by_diff( x, p, epsilon = c( 0.000001, 0.000001, 0.000001 ), debug = FALSE, implementation = "C" )
x |
data vector |
p |
initialization vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
epsilon |
tolerance threshold for convergence. Structure of epsilon is epsilon = c( epsilon_A, epsilon_mu, epsilon_k ), where epsilon_A is threshold for component proportions, epsilon_mu is threshold for component centers and epsilon_k is threshold for component concentrations. |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Banerjee et al. Expectation Maximization for Clustering on Hyperspheres (2003), manuscript, accessible on: https://web.archive.org/web/20130120061240/http://www.lans.ece.utexas.edu/~abanerjee/papers/05/banerjee05a.pdf
Estimates parameters for univariate von Mises mixture using Expectation Maximization algorithm. In this version stopping criterion is the difference between log-likelihood estimates of subsequent iterations.
vmm_fit_em_by_ll( x, p, epsilon = .Machine$double.eps, debug = FALSE, implementation = "C" )vmm_fit_em_by_ll( x, p, epsilon = .Machine$double.eps, debug = FALSE, implementation = "C" )
x |
data vector |
p |
initialization vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component. |
epsilon |
tolerance threshold for convergence |
debug |
flag to turn the debug prints on/off. |
implementation |
flag to switch between C (default) and R implementations. |
Vector of mixture parameters, whose structure is the same as of input parameter's p.
Andrius Merkys
Banerjee et al. Expectation Maximization for Clustering on Hyperspheres (2003), manuscript, accessible on: https://web.archive.org/web/20130120061240/http://www.lans.ece.utexas.edu/~abanerjee/papers/05/banerjee05a.pdf
Estimate an initialization vector for von Mises mixture fitting via Expectation Maximization. Proportions are set to equal, centers are equispaced through the whole domain of input sample, and concentrations are set to (m/(12*180))^2.
vmm_init_vector( m, implementation = "C" )vmm_init_vector( m, implementation = "C" )
m |
number of mixture components |
implementation |
flag to switch between C (default) and R implementations. |
Parameter vector of 3*n parameters, where n is number of mixture components. Structure of p vector is p = c( A1, A2, ..., An, mu1, mu2, ..., mun, k1, k2, ..., kn ), where Ai is the proportion of i-th component, mui is the center of i-th component and ki is the concentration of i-th component.
Andrius Merkys
Calculated weighted median.
wmedian( x, w, start = 1, end = length( x ) )wmedian( x, w, start = 1, end = length( x ) )
x |
sample vector |
w |
weights vector |
start |
start index (default: 1) |
end |
end index (default: last index in x) |
Median
Andrius Merkys
Users of Wikipedia. Weighted median. https://en.wikipedia.org/w/index.php?title=Weighted_median&oldid=690896947