Package gov.nih.mipav.model.algorithms
Class Fastfit
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.Fastfit
-
public class Fastfit extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
CACHE_SIZE
double
epsilon
Original C and MATLAB code from fastfit and lightspeed packages by Tom Minka.(package private) static long
ix
(package private) static long
iy
(package private) static long
iz
(package private) static double
RandN_previous
(package private) static int
RandN_usePrevious
-
Constructor Summary
Constructors Constructor Description Fastfit()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
BetaRand(double a, double b)
long
BinoRand(double p, long n)
double[][]
cholproj(double[][] A, boolean[] isPosDef)
double[]
col_sum(double[][] x)
double
di_pochhammer(double x, double n)
double
di_pochhammer(double x, int n)
double
digamma(double x)
double[]
dirichlet_fit(double[] e, double[][] data, double[] ain, double[] bar_p)
double[]
dirichlet_fit_m(double[][] data, double[] ain, double[] bar_p, int niter)
double[]
dirichlet_fit_newton(double[] e, double[][] data, double[] ain, double[] bar_p)
double[]
dirichlet_fit_s(double[][] data, double[] ain, double[] bar_p, int niter)
double[]
dirichlet_fit_simple(double[] e, double[][] data, double[] ain)
double[]
dirichlet_logProb(double[] a, double[][] data)
double
dirichlet_logProb_fast(double[] a, double[] meanlog)
double[]
dirichlet_moment_match(double[][] p)
double[][]
dirichlet_sample(double[][] a, int n)
double[][]
dirichlet_sample_col(double[] acol, int n)
void
gamma_fit(double[] a, double[] b, double[] x, double s)
(package private) double
gammaln(double x)
(package private) double
gammaln2(double x, double d)
double
GammaRand(double a)
void
GetSeed(long[] ix_out, long[] iy_out, long[] iz_out)
double[]
gradient2(double[] a, double[][] data, double[] sdata)
double[]
hessian_times_gradient(double[] a, double[] g, double lambda)
double[]
hessian_times_gradient2(double[] a, double[][] data, double[] sdata, double[] g, double lambda)
double
inv_digamma(double y, int niter)
double[][]
inv_posdef(double[][] A)
double[][]
inv_triu(double[][] U)
double
invnormcdf(double p)
double
logdet(double[][] A)
double[][]
logmulexp(double[][] a, double[][] b)
double[]
logsumexp(double[][] ain, int dim)
double[]
mvnormpdf(double[][] x, double[][] m, double[][] S, double[][] iS, double[][] V, double[][] iV)
double[]
mvnormpdfln(double[][] x, double[][] m, double[][] S, double[][] iS, double[][] V, double[][] iV)
double
normcdf(double x, double m, double s)
double
normcdfln(double x)
double
normcdflogit(double x)
double
pochhammer(double x, double n)
double
pochhammer(double x, int n)
double[]
polya_fit(double[][] data, double[] ain)
double[]
polya_fit_m(double[][] data, double[] ain, double[] weight)
double[]
polya_fit_ms(double[][] data, double[] ain, double[] weight)
double[]
polya_fit_s(double[][] data, double[] ain, double[] weight)
double[]
polya_fit_simple(double[][] data, double[] ain)
double[]
polya_logProb(double[] a, double[][] data)
double[]
polya_moment_match(double[][] data)
double[][]
polya_sample(double[][] a, int[] n)
void
quad_roots(double[] r1, double[] r2, double a2, double a1, double a0)
double
Rand()
double
RandN()
double[][]
randwishart(double a, int d)
void
ResetSeed()
double[]
row_sum(double[][] x)
void
s_derivatives(double[] g, double[] h, double[] c1, double[] c3, double[] a, double[][] data, double[] sdata, double[] weight)
void
s_derivatives_c(double[] g, double[] h, double[] c1, double[] c3, double[] a, double[][] data, double[] len, double[] weight)
double[][]
sample_hist(double[][] p, int[] n)
void
SetSeed(long new_ix, long new_iy, long new_iz)
double
slow_di_pochhammer(double x, int n)
double
slow_pochhammer(double x, int n)
double
slow_tri_pochhammer(double x, int n)
double[][]
solve_tril(double[][] T, double[][] b)
double[][]
solve_tril2(double[][] T, double[][] b)
double[][]
solve_triu(double[][] T, double[][] b)
double[][]
solve_triu2(double[][] T, double[][] b)
double
special_case(double s, double g, double h, double c1, double c3)
double[][]
sqdist(double[][] p, double[][] q, double[][] A)
void
test_cholproj()
void
test_digamma()
void
test_dirichlet_fit()
void
test_dirichlet_sample()
void
test_gamma_fit()
void
test_gammaln()
void
test_inv_posdef()
void
test_logmulexp()
void
test_logsumexp()
void
test_normcdf()
void
test_pochhammer()
void
test_polya_fit()
void
test_randgamma()
void
test_randwishart()
void
test_solve_tri()
void
test_trigamma()
void
test_wishpdf()
double
tetragamma(double x)
double
tri_pochhammer(double x, double n)
double
tri_pochhammer(double x, int n)
double
trigamma(double x)
double
wishpdf(double[][] X, double a, double[][] B, boolean inverse)
double
wishpdf(double X, double a, double B, boolean inverse)
double
wishpdfln(double[][] Xin, double a, double[][] B, boolean inverse)
double
wishpdfln(double X, double a, double B, boolean inverse)
-
-
-
Field Detail
-
epsilon
public double epsilon
Original C and MATLAB code from fastfit and lightspeed packages by Tom Minka. Ported to Java by William Gandler Fastfit ======= This toolbox implements efficient maximum-likelihood estimation of various distributions. It utilizes the technique of generalized Newton iteration, described in the following papers: [Beyond Newton's method](http://tminka.github.io/papers/newton.html) [Estimating a Dirichlet distribution](http://tminka.github.io/papers/dirichlet/) [Estimating a Gamma distribution](http://tminka.github.io/papers/minka-gamma.pdf) This toolbox requires the [Lightspeed toolbox](https://github.com/tminka/lightspeed/), so you will need to install both. See Contents.m for more details. A python port is available at https://github.com/ericsuh/dirichlet Tom Minka Lightspeed matlab toolbox ========================= This library provides: highly optimized versions of mathematical functions such as `normcdf`, set intersection, and `gammaln` efficient random number generators evaluation of common probability densities routines for counting floating-point operations (FLOPS), useful for benchmarking algorithms. utilities such as filename globbing and parsing of variable-length argument lists. graphics functions such as `axis_pct` and `mobile_text` (in the graphics subdirectory). See Contents.m for a table of contents. Tom Minka MIT License Copyright (c) 2017 Tom Minka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
ix
static long ix
-
iy
static long iy
-
iz
static long iz
-
RandN_previous
static double RandN_previous
-
RandN_usePrevious
static int RandN_usePrevious
-
CACHE_SIZE
int CACHE_SIZE
-
-
Method Detail
-
test_digamma
public void test_digamma()
-
digamma
public double digamma(double x)
-
test_trigamma
public void test_trigamma()
-
trigamma
public double trigamma(double x)
-
tetragamma
public double tetragamma(double x)
-
Rand
public double Rand()
-
ResetSeed
public void ResetSeed()
-
SetSeed
public void SetSeed(long new_ix, long new_iy, long new_iz)
-
GetSeed
public void GetSeed(long[] ix_out, long[] iy_out, long[] iz_out)
-
RandN
public double RandN()
-
test_randgamma
public void test_randgamma()
-
GammaRand
public double GammaRand(double a)
-
BetaRand
public double BetaRand(double a, double b)
-
BinoRand
public long BinoRand(double p, long n)
-
logdet
public double logdet(double[][] A)
-
test_randwishart
public void test_randwishart()
-
randwishart
public double[][] randwishart(double a, int d)
-
test_logsumexp
public void test_logsumexp()
-
logsumexp
public double[] logsumexp(double[][] ain, int dim)
-
test_logmulexp
public void test_logmulexp()
-
logmulexp
public double[][] logmulexp(double[][] a, double[][] b)
-
test_normcdf
public void test_normcdf()
-
normcdf
public double normcdf(double x, double m, double s)
-
normcdfln
public double normcdfln(double x)
-
normcdflogit
public double normcdflogit(double x)
-
test_cholproj
public void test_cholproj()
-
cholproj
public double[][] cholproj(double[][] A, boolean[] isPosDef)
-
gammaln2
double gammaln2(double x, double d)
-
test_gammaln
public void test_gammaln()
-
gammaln
double gammaln(double x)
-
wishpdfln
public double wishpdfln(double X, double a, double B, boolean inverse)
-
wishpdfln
public double wishpdfln(double[][] Xin, double a, double[][] B, boolean inverse)
-
test_wishpdf
public void test_wishpdf()
-
wishpdf
public double wishpdf(double X, double a, double B, boolean inverse)
-
wishpdf
public double wishpdf(double[][] X, double a, double[][] B, boolean inverse)
-
test_pochhammer
public void test_pochhammer()
-
pochhammer
public double pochhammer(double x, double n)
-
pochhammer
public double pochhammer(double x, int n)
-
slow_pochhammer
public double slow_pochhammer(double x, int n)
-
di_pochhammer
public double di_pochhammer(double x, double n)
-
di_pochhammer
public double di_pochhammer(double x, int n)
-
slow_di_pochhammer
public double slow_di_pochhammer(double x, int n)
-
tri_pochhammer
public double tri_pochhammer(double x, double n)
-
tri_pochhammer
public double tri_pochhammer(double x, int n)
-
slow_tri_pochhammer
public double slow_tri_pochhammer(double x, int n)
-
solve_tril
public double[][] solve_tril(double[][] T, double[][] b)
-
solve_tril2
public double[][] solve_tril2(double[][] T, double[][] b)
-
test_solve_tri
public void test_solve_tri()
-
solve_triu
public double[][] solve_triu(double[][] T, double[][] b)
-
solve_triu2
public double[][] solve_triu2(double[][] T, double[][] b)
-
inv_triu
public double[][] inv_triu(double[][] U)
-
test_inv_posdef
public void test_inv_posdef()
-
inv_posdef
public double[][] inv_posdef(double[][] A)
-
invnormcdf
public double invnormcdf(double p)
-
col_sum
public double[] col_sum(double[][] x)
-
row_sum
public double[] row_sum(double[][] x)
-
mvnormpdf
public double[] mvnormpdf(double[][] x, double[][] m, double[][] S, double[][] iS, double[][] V, double[][] iV)
-
mvnormpdfln
public double[] mvnormpdfln(double[][] x, double[][] m, double[][] S, double[][] iS, double[][] V, double[][] iV)
-
sqdist
public double[][] sqdist(double[][] p, double[][] q, double[][] A)
-
test_dirichlet_sample
public void test_dirichlet_sample()
-
dirichlet_sample
public double[][] dirichlet_sample(double[][] a, int n)
-
dirichlet_sample_col
public double[][] dirichlet_sample_col(double[] acol, int n)
-
dirichlet_moment_match
public double[] dirichlet_moment_match(double[][] p)
-
dirichlet_fit_s
public double[] dirichlet_fit_s(double[][] data, double[] ain, double[] bar_p, int niter)
-
dirichlet_logProb
public double[] dirichlet_logProb(double[] a, double[][] data)
-
dirichlet_fit_m
public double[] dirichlet_fit_m(double[][] data, double[] ain, double[] bar_p, int niter)
-
inv_digamma
public double inv_digamma(double y, int niter)
-
dirichlet_logProb_fast
public double dirichlet_logProb_fast(double[] a, double[] meanlog)
-
test_dirichlet_fit
public void test_dirichlet_fit()
-
dirichlet_fit
public double[] dirichlet_fit(double[] e, double[][] data, double[] ain, double[] bar_p)
-
dirichlet_fit_simple
public double[] dirichlet_fit_simple(double[] e, double[][] data, double[] ain)
-
dirichlet_fit_newton
public double[] dirichlet_fit_newton(double[] e, double[][] data, double[] ain, double[] bar_p)
-
hessian_times_gradient
public double[] hessian_times_gradient(double[] a, double[] g, double lambda)
-
test_gamma_fit
public void test_gamma_fit()
-
gamma_fit
public void gamma_fit(double[] a, double[] b, double[] x, double s)
-
polya_moment_match
public double[] polya_moment_match(double[][] data)
-
polya_logProb
public double[] polya_logProb(double[] a, double[][] data)
-
gradient2
public double[] gradient2(double[] a, double[][] data, double[] sdata)
-
hessian_times_gradient2
public double[] hessian_times_gradient2(double[] a, double[][] data, double[] sdata, double[] g, double lambda)
-
polya_fit
public double[] polya_fit(double[][] data, double[] ain)
-
polya_fit_simple
public double[] polya_fit_simple(double[][] data, double[] ain)
-
polya_fit_m
public double[] polya_fit_m(double[][] data, double[] ain, double[] weight)
-
quad_roots
public void quad_roots(double[] r1, double[] r2, double a2, double a1, double a0)
-
special_case
public double special_case(double s, double g, double h, double c1, double c3)
-
s_derivatives_c
public void s_derivatives_c(double[] g, double[] h, double[] c1, double[] c3, double[] a, double[][] data, double[] len, double[] weight)
-
s_derivatives
public void s_derivatives(double[] g, double[] h, double[] c1, double[] c3, double[] a, double[][] data, double[] sdata, double[] weight)
-
polya_fit_s
public double[] polya_fit_s(double[][] data, double[] ain, double[] weight)
-
polya_fit_ms
public double[] polya_fit_ms(double[][] data, double[] ain, double[] weight)
-
polya_sample
public double[][] polya_sample(double[][] a, int[] n)
-
sample_hist
public double[][] sample_hist(double[][] p, int[] n)
-
test_polya_fit
public void test_polya_fit()
-
-