2 .TH linreg 3 "9 March 2024" "Straylight/Edgeware" "mLib utilities library"
10 .B "#include <mLib/linreg.h>"
12 .B "struct linreg { ...\& };"
13 .B "#define LINREG_INIT ..."
15 .BI "void linreg_init(struct linreg *" lr );
16 .BI "void linreg_update(struct linreg *" lr ", double " x ", double " y );
17 .ta \w'void linreg_fit('u
18 .BI "void linreg_fit(struct linreg *" lr ,
19 .BI " double *" m_out ", double *" c_out ", double *" r_out );
23 The functions declared in the
25 header perform simple linear regression.
27 The state for a linear regression is held in a
29 Such a structure can be initialized statically,
32 or dynamically, by calling the
36 Once a state is initialized,
39 can be added by calling
41 Each call just performs a small and constant amount of computation;
42 the linear regression state uses a constant amount of storage
43 independent of the number of points.
47 function will return the results of the regression.
48 It calculates quantities
53 .IR y "\ =\ " m "\ " x "\ +\ " c
54 is a reasonable approximation to the data points provided,
55 and a correlation coefficient
57 quantifying how good this approximation is.
58 These quantities are stored in
64 any (or all, but that wouldn't be useful) of these pointers may be null,
65 to discard the corresponding output.
67 The linear regression state can be discarded without need for ceremony:
68 it holds no external resources.
70 Any half-decent introduction to statistics will explain these concepts.
73 Mark Wooding, <mdw@distorted.org.uk>