TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcmodel
mestim.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
#include "
libtpcmodel.h
"
7
/*****************************************************************************/
8
9
/*****************************************************************************/
18
double
mEstim
(
20
double
*data,
22
int
nr,
24
int
iterNr,
26
double
cutoff
27
) {
28
double
theta, sum1, sum2, help;
29
30
theta=
dmedian
(data, nr);
31
for
(
int
ii=0; ii<iterNr; ii++){
32
sum1=sum2=0;
33
for
(
int
in=0; in<nr; in++){
34
if
(data[in]<0.9999*theta || data[in]>1.0001*theta){
35
help=
huber
(data[in]-theta, cutoff);
36
sum1=sum1+data[in]*help/(data[in]-theta);
37
sum2=sum2+help/(data[in]-theta);
38
}
else
{
39
sum1=sum1+cutoff*data[in];
40
sum2=sum2+cutoff;
41
}
42
}
43
theta=sum1/sum2;
44
}
45
return
theta;
46
}
47
/*****************************************************************************/
48
49
/*****************************************************************************/
53
double
huber
(
55
double
x,
57
double
b
58
) {
59
double
help;
60
61
if
(x<-b) help=-b;
else
help=x;
62
if
(help<b) {
return
help;}
else
{
return
b;}
63
}
64
/*****************************************************************************/
65
66
/*****************************************************************************/
libtpcmodel.h
Header file for libtpcmodel.
dmedian
double dmedian(double *data, int n)
Definition
median.c:48
huber
double huber(double x, double b)
Definition
mestim.c:53
mEstim
double mEstim(double *data, int nr, int iterNr, double cutoff)
Definition
mestim.c:18
Generated on
for TPCCLIB by
1.17.0