3 .\" Manual for linear regression
5 .\" (c) 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH linreg 3mLib "9 March 2024" "Straylight/Edgeware" "mLib utilities library"
37 .\"--------------------------------------------------------------------------
39 lineag \- linear regression
41 .\"--------------------------------------------------------------------------
44 .B "#include <mLib/linreg.h>"
46 .B "struct linreg { ...\& };"
47 .B "#define LINREG_INIT ..."
49 .BI "void linreg_init(struct linreg *" lr );
50 .BI "void linreg_update(struct linreg *" lr ", double " x ", double " y );
51 .ta \w'void linreg_fit('u
52 .BI "void linreg_fit(struct linreg *" lr ,
53 .BI " double *" m_out ", double *" c_out ", double *" r_out );
56 .\"--------------------------------------------------------------------------
59 The functions declared in the
61 header perform simple linear regression.
63 The state for a linear regression is held in a
65 Such a structure can be initialized statically,
68 or dynamically, by calling the
72 Once a state is initialized,
75 can be added by calling
77 Each call just performs a small and constant amount of computation;
78 the linear regression state uses a constant amount of storage
79 independent of the number of points.
83 function will return the results of the regression.
84 It calculates quantities
89 .IR y "\ =\ " m "\ " x "\ +\ " c
90 is a reasonable approximation to the data points provided,
91 and a correlation coefficient
93 quantifying how good this approximation is.
94 These quantities are stored in
100 any (or all, but that wouldn't be useful) of these pointers may be null,
101 to discard the corresponding output.
103 The linear regression state can be discarded without need for ceremony:
104 it holds no external resources.
106 Any half-decent introduction to statistics will explain these concepts.
108 .\"--------------------------------------------------------------------------
113 .\"--------------------------------------------------------------------------
116 Mark Wooding, <mdw@distorted.org.uk>
118 .\"----- That's all, folks --------------------------------------------------