MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / lrbuilds

Function lrbuilds

src/linreg.cpp:134–231  ·  view source on GitHub ↗

Linear regression Variant of LRBuild which uses vector of standatd deviations (errors in function values). INPUT PARAMETERS: XY - training set, array [0..NPoints-1,0..NVars]: * NVars columns - independent variables * last column - dependent variable S - standard deviations (errors in function values) array

Source from the content-addressed store, hash-verified

132 Copyright 02.08.2008 by Bochkanov Sergey
133*************************************************************************/
134void lrbuilds(const ap::real_2d_array& xy,
135 const ap::real_1d_array& s,
136 int npoints,
137 int nvars,
138 int& info,
139 linearmodel& lm,
140 lrreport& ar)
141{
142 ap::real_2d_array xyi;
143 ap::real_1d_array x;
144 ap::real_1d_array means;
145 ap::real_1d_array sigmas;
146 int i;
147 int j;
148 double v;
149 int offs;
150 double mean;
151 double variance;
152 double skewness;
153 double kurtosis;
154
155
156 //
157 // Test parameters
158 //
159 if( npoints<=nvars+1||nvars<1 )
160 {
161 info = -1;
162 return;
163 }
164
165 //
166 // Copy data, add one more column (constant term)
167 //
168 xyi.setbounds(0, npoints-1, 0, nvars+1);
169 for(i = 0; i <= npoints-1; i++)
170 {
171 ap::vmove(&xyi(i, 0), 1, &xy(i, 0), 1, ap::vlen(0,nvars-1));
172 xyi(i,nvars) = 1;
173 xyi(i,nvars+1) = xy(i,nvars);
174 }
175
176 //
177 // Standartization
178 //
179 x.setbounds(0, npoints-1);
180 means.setbounds(0, nvars-1);
181 sigmas.setbounds(0, nvars-1);
182 for(j = 0; j <= nvars-1; j++)
183 {
184 ap::vmove(&x(0), 1, &xy(0, j), xy.getstride(), ap::vlen(0,npoints-1));
185 calculatemoments(x, npoints, mean, variance, skewness, kurtosis);
186 means(j) = mean;
187 sigmas(j) = sqrt(variance);
188 if( ap::fp_eq(sigmas(j),0) )
189 {
190 sigmas(j) = 1;
191 }

Callers 1

lrbuildFunction · 0.85

Calls 8

vmoveFunction · 0.85
calculatemomentsFunction · 0.85
lrinternalFunction · 0.85
round_fFunction · 0.85
vsubFunction · 0.85
vmulFunction · 0.85
getstrideMethod · 0.80
setboundsMethod · 0.45

Tested by

no test coverage detected