TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcmodels
aic.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <math.h>
10
#include <time.h>
11
#include <string.h>
12
/*****************************************************************************/
13
#include "
tpcextensions.h
"
14
/*****************************************************************************/
15
#include "
tpcmodels.h
"
16
/*****************************************************************************/
17
18
/*****************************************************************************/
29
double
aicSS
(
31
double
ss,
33
const
unsigned
int
n,
36
const
unsigned
int
k
37
) {
38
if
(!(ss>=0.0) || n<1 || (n-k)<2)
return
(nan(
""
));
39
40
int
dr=n-k-1;
41
int
dv=2*k*(k+1);
42
double
aic=0.0, bias_adj=0.0, css;
43
if
(dr>0) bias_adj=((double)dv)/((
double
)dr);
else
bias_adj=0.0;
44
if
(ss<1.0e-50) css=1.0e-50;
else
css=ss;
/* Because log(0) is an error */
45
aic= n*log(css/(
double
)n) + 2.0*(double)k + bias_adj;
46
return
(aic);
47
}
48
/*****************************************************************************/
49
50
/*****************************************************************************/
60
unsigned
int
parFreeNr
(
62
const
unsigned
int
n,
64
double
*pLower,
66
double
*pUpper
67
) {
68
if
(n==0 || pLower==NULL || pUpper==NULL)
return
(0);
69
unsigned
int
nf=0;
70
for
(
unsigned
int
i=0; i<n; i++) {
71
double
range=pUpper[i]-pLower[i];
72
if
(range>1.0E-10) nf++;
73
}
74
return
(nf);
75
}
76
/*****************************************************************************/
77
78
/*****************************************************************************/
aicSS
double aicSS(double ss, const unsigned int n, const unsigned int k)
Calculate corrected AIC.
Definition
aic.c:29
parFreeNr
unsigned int parFreeNr(const unsigned int n, double *pLower, double *pUpper)
Calculate the number of free parameters.
Definition
aic.c:60
tpcextensions.h
Header file for library libtpcextensions.
tpcmodels.h
Header file for libtpcmodels.
Generated on
for TPCCLIB by
1.17.0