X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmath%2Fcoefficient.h;h=705c1e0e488f3927483946b62f37815c144cc599;hb=5cc5058cfb4e7f3c22e7c53c7f538e73cc642c64;hp=0dc1a0353943b67e81e1a7bf5d73f4b4a4692874;hpb=c21a0f82e238fe80b61d8ab00e21ec32c753ca2f;p=pspp-builds.git diff --git a/src/math/coefficient.h b/src/math/coefficient.h index 0dc1a035..705c1e0e 100644 --- a/src/math/coefficient.h +++ b/src/math/coefficient.h @@ -1,32 +1,37 @@ -/* - lib/linreg/coefficient.c - - Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover. - - This program is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 51 - Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. -*/ +/* PSPP - a program for statistical analysis. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #ifndef COEFFICIENT_H #define COEFFICIENT_H #include -#include #include #include +/* + This file contains definitions of data structures for storing + coefficients of a statistical model. The coefficients are the point + in the model where the theoretical aspects of the model meet the + data. As such, the coefficients are the interface where users need + to match variable names and values with any information about the + model itself. This file and coefficient.c provide this interface + between data and model structures. + */ + struct design_matrix; /* @@ -35,7 +40,7 @@ struct design_matrix; storage. Therefore non-essential members of the struct will be allocated only when requested. */ -struct pspp_linreg_coeff +struct pspp_coeff { double estimate; /* Estimated coefficient. */ double std_err; /* Standard error of the estimate. */ @@ -54,22 +59,22 @@ struct pspp_linreg_coeff interaction terms will have more than one variable. */ }; +typedef struct pspp_coeff coefficient; - -void pspp_linreg_coeff_free (struct pspp_linreg_coeff *); +void pspp_coeff_free (struct pspp_coeff *); /* Initialize the variable and value pointers inside the coefficient structures for the linear model. */ -void pspp_linreg_coeff_init (pspp_linreg_cache *, struct design_matrix *); +void pspp_coeff_init (struct pspp_coeff **, const struct design_matrix *); void -pspp_linreg_coeff_set_estimate (struct pspp_linreg_coeff *, double estimate); +pspp_coeff_set_estimate (struct pspp_coeff *, double estimate); void -pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err); +pspp_coeff_set_std_err (struct pspp_coeff *, double std_err); /* Accessor functions for matching coefficients and variables. @@ -78,33 +83,48 @@ pspp_linreg_coeff_set_std_err (struct pspp_linreg_coeff *, double std_err); /* Return the estimated value of the coefficient. */ -double pspp_linreg_coeff_get_est (const struct pspp_linreg_coeff *); +double pspp_coeff_get_est (const struct pspp_coeff *); /* Return the standard error of the estimated coefficient. */ -double pspp_linreg_coeff_get_std_err (const struct pspp_linreg_coeff *); +double pspp_coeff_get_std_err (const struct pspp_coeff *); /* How many variables are associated with this coefficient? */ -int pspp_linreg_coeff_get_n_vars (struct pspp_linreg_coeff *); +int pspp_coeff_get_n_vars (struct pspp_coeff *); + +/* + Which coefficient does this variable match? If the variable is + categorical, and has more than one coefficient, report the first + coefficient found. Note that in this case, the result will depend on + the order of COEFS. + */ +struct pspp_coeff * +pspp_coeff_var_to_coeff (const struct variable *, struct pspp_coeff **, size_t, const union value *); /* Which variable does this coefficient match? The int argument is usually 0, unless the coefficient refers to an interaction. */ -const struct variable *pspp_linreg_coeff_get_var (struct pspp_linreg_coeff *, +const struct variable *pspp_coeff_get_var (struct pspp_coeff *, int); /* Which value is associated with this coefficient/variable comination? */ -const union value *pspp_linreg_coeff_get_value (struct pspp_linreg_coeff *, +const union value *pspp_coeff_get_value (struct pspp_coeff *, const struct variable *); -const struct pspp_linreg_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache - *, - const struct variable - *, - const union value *); +/* + Get or set the standard deviation of the variable associated with this coefficient. + */ +double pspp_coeff_get_sd (const struct pspp_coeff *); +void pspp_coeff_set_sd (struct pspp_coeff *, double); + +/* + Get or set the mean for the variable associated with this coefficient. +*/ +double pspp_coeff_get_mean (const struct pspp_coeff *); +void pspp_coeff_set_mean (struct pspp_coeff *, double); #endif