File indexing completed on 2024-05-19 03:49:03
0001 /* 0002 File : nsl_sf_stats.c 0003 Project : LabPlot 0004 Description : NSL special statistics functions 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2016-2017 Stefan Gerlach <stefan.gerlach@uni.kn> 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include "nsl_sf_stats.h" 0011 #include "nsl_common.h" 0012 0013 const char* nsl_sf_stats_distribution_name[] = {i18n("Gaussian (Normal)"), 0014 i18n("Gaussian Tail"), 0015 i18n("Exponential"), 0016 i18n("Laplace"), 0017 i18n("Exponential Power"), 0018 i18n("Cauchy-Lorentz (Breit-Wigner)"), 0019 i18n("Rayleigh"), 0020 i18n("Rayleigh Tail"), 0021 i18n("Landau"), 0022 i18n("Levy Alpha-stable"), 0023 i18n("Levy Skew Alpha-stable"), 0024 i18n("Gamma"), 0025 i18n("Flat (Uniform)"), 0026 i18n("Log-Normal (Galton)"), 0027 i18n("Chi-Squared"), 0028 i18n("F (Fisher-Snedecor)"), 0029 i18n("Student's t"), 0030 i18n("Beta"), 0031 i18n("Logistic (Sech-Squared)"), 0032 i18n("Pareto"), 0033 i18n("Weibull"), 0034 i18n("Gumbel Type-1 (Maximum Value; log-Weibull)"), 0035 i18n("Gumbel Type-2"), 0036 i18n("Poisson"), 0037 i18n("Bernoulli"), 0038 i18n("Binomial"), 0039 i18n("Negative Binomial"), 0040 i18n("Pascal"), 0041 i18n("Geometric"), 0042 i18n("Hypergeometric"), 0043 i18n("Logarithmic"), 0044 i18n("Maxwell-Boltzmann"), 0045 i18n("Hyperbolic Secant (sech)"), 0046 i18n("Levy"), 0047 i18n("Frechet (Inverse Weibull)")}; 0048 const char* nsl_sf_stats_distribution_pic_name[] = {"gaussian", 0049 "gaussian_tail", 0050 "exponential", 0051 "laplace", 0052 "exponential_power", 0053 "cauchy_lorentz", 0054 "rayleigh", 0055 "rayleigh_tail", 0056 "landau", 0057 "levy_alpha_stable", 0058 "levy_skew_alpha_stable", 0059 "gamma", 0060 "flat", 0061 "lognormal", 0062 "chi_squared", 0063 "fdist", 0064 "students_t", 0065 "beta", 0066 "logistic", 0067 "pareto", 0068 "weibull", 0069 "gumbel1", 0070 "gumbel2", 0071 "poisson", 0072 "bernoulli", 0073 "binomial", 0074 "negative_binomial", 0075 "pascal", 0076 "geometric", 0077 "hypergeometric", 0078 "logarithmic", 0079 "maxwell_boltzmann", 0080 "sech", 0081 "levy", 0082 "frechet"}; 0083 const char* nsl_sf_stats_distribution_equation[] = {"a/sqrt(2*pi)/s * exp(-((x-mu)/s)^2/2)", 0084 "2*A/sqrt(2*pi)/s/erfc(a/sqrt(2)/s) * exp(-((x-mu)/s)^2/2) * theta(x-mu-a)", 0085 "a*l*exp(-l*(x-mu))", 0086 "a/(2*s) * exp(-fabs((x-mu)/s))", 0087 "a/(2*s*gamma(1+1/b))*exp(-fabs((x-mu)/s)^b)", 0088 "a/pi * g/(g^2 + (x-mu)^2)", 0089 "a * x/s^2 * exp(-(x/s)^2/2)", 0090 "a*x/s^2 * exp((mu^2-x^2)/2/s^2)", 0091 "a*landau(x)", 0092 "Levy alpha-stable", 0093 "Levy-skew", 0094 "a/gamma(k)/t^k * x^(k-1)*exp(-x/t)", 0095 "A/(b-a)*theta(b-x)*theta(x-a)", 0096 "a/sqrt(2*pi)/x/s * exp(-( (log(x)-mu)/s )^2/2)", 0097 "a * x^(n/2.-1.)/2^(n/2.)/gamma(n/2.) * exp(-x/2.)", 0098 "a * fdist(x, n1, n2)", 0099 "a*gamma((n+1)/2)/sqrt(pi*n)/gamma(n/2) * (1+x^2/n)^(-(n+1)/2)", 0100 "A*gamma(a+b)/gamma(a)/gamma(b) * x^(a-1) * (1-x)^(b-1)", 0101 "a/4/s * sech((x-mu)/2/s)**2", 0102 "a/b * (b/x)^(a+1) * theta(x-b)", 0103 "a * k/l * ((x-mu)/l)^(k-1) * exp(-((x-mu)/l)^k)", 0104 "a/s * exp(-(x-mu)/s - b*exp(-(x-mu)/s))", 0105 "A*a*b * (x-mu)^(-a-1) * exp(-b*(x-mu)^(-a))", 0106 "a * l^x/gamma(x+1) * exp(-l)", 0107 "Bernoulli", 0108 "a * binomial(x, p, n)", 0109 "a * negative_binomial(x, p, n)", 0110 "a * pascal(x, p, n)", 0111 "a * geometric(x, p)", 0112 "a * hypergeometric(x, n1, n2, t)", 0113 "a * logarithmic(x, p)", 0114 "a*sqrt(2/pi) * x^2/s^3 * exp(-(x/s)^2/2)", 0115 "a/2/s * sech(pi/2*(x-mu)/s)", 0116 "a * sqrt(g/(2*pi))/pow(x-mu, 1.5) * exp(-g/2./(x-mu))", 0117 "a * g/s*((x-mu)/s)^(-g-1) * exp(-((x-mu)/s)^(-g))"}; 0118 0119 bool nsl_sf_stats_distribution_supports_ML(nsl_sf_stats_distribution d) { 0120 if (d == nsl_sf_stats_gaussian || d == nsl_sf_stats_exponential || d == nsl_sf_stats_laplace || d == nsl_sf_stats_cauchy_lorentz 0121 || d == nsl_sf_stats_lognormal || d == nsl_sf_stats_poisson || d == nsl_sf_stats_binomial) 0122 return true; 0123 0124 return false; 0125 }