liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
regress_simple.h
Go to the documentation of this file.
1
7#ifndef LIBA_REGRESS_SIMPLE_H
8#define LIBA_REGRESS_SIMPLE_H
9
10#include "a.h"
11
19
20#if defined(__cplusplus)
21extern "C" {
22#endif /* __cplusplus */
23
30A_EXTERN void a_regress_simple_init(a_regress_simple *ctx, a_float coef, a_float bias);
31
39
47
57A_EXTERN void a_regress_simple_ols_(a_regress_simple *ctx, a_size n, a_float const *x, a_float const *y, a_float x_mean, a_float y_mean);
58
67A_EXTERN void a_regress_simple_olsx(a_regress_simple *ctx, a_size n, a_float const *x, a_float const *y, a_float x_mean);
68
77A_EXTERN void a_regress_simple_olsy(a_regress_simple *ctx, a_size n, a_float const *x, a_float const *y, a_float y_mean);
78
86A_EXTERN void a_regress_simple_ols(a_regress_simple *ctx, a_size n, a_float const *x, a_float const *y);
87
93
94#if defined(__cplusplus)
95} /* extern "C" */
96namespace a
97{
98typedef struct a_regress_simple regress_simple;
99} /* namespace a */
100#endif /* __cplusplus */
101
106{
107 a_float coef; // regression coefficient
108 a_float bias; // intercept
109#if defined(__cplusplus)
110 A_INLINE void init(a_float a = 1, a_float b = 0)
111 {
112 a_regress_simple_init(this, a, b);
113 }
114 A_INLINE a_float eval(a_float val) const
115 {
116 return a_regress_simple_eval(this, val);
117 }
118 A_INLINE a_float evar(a_float val) const
119 {
120 return a_regress_simple_evar(this, val);
121 }
122 A_INLINE void ols(a_size n, a_float const *x, a_float const *y, a_float x_mean, a_float y_mean)
123 {
124 a_regress_simple_ols_(this, n, x, y, x_mean, y_mean);
125 }
126 A_INLINE void olsx(a_size n, a_float const *x, a_float const *y, a_float x_mean)
127 {
128 a_regress_simple_olsx(this, n, x, y, x_mean);
129 }
130 A_INLINE void olsy(a_size n, a_float const *x, a_float const *y, a_float y_mean)
131 {
132 a_regress_simple_olsy(this, n, x, y, y_mean);
133 }
134 A_INLINE void ols(a_size n, a_float const *x, a_float const *y)
135 {
136 a_regress_simple_ols(this, n, x, y);
137 }
138 A_INLINE void zero() { a_regress_simple_zero(this); }
139#endif /* __cplusplus */
140};
141
144#endif /* a/regress_simple.h */
algorithm library
#define a_float
Definition a.h:785
void a_regress_simple_zero(a_regress_simple *ctx)
zeroing for simple linear regression
void a_regress_simple_ols(a_regress_simple *ctx, size_t n, double const *x, double const *y)
ordinary least squares for simple linear regression
void a_regress_simple_olsx(a_regress_simple *ctx, size_t n, double const *x, double const *y, double x_mean)
ordinary least squares for simple linear regression
void a_regress_simple_olsy(a_regress_simple *ctx, size_t n, double const *x, double const *y, double y_mean)
ordinary least squares for simple linear regression
void a_regress_simple_ols_(a_regress_simple *ctx, size_t n, double const *x, double const *y, double x_mean, double y_mean)
ordinary least squares for simple linear regression
double a_regress_simple_evar(a_regress_simple const *ctx, double val)
calculate predicted value for simple linear regression
double a_regress_simple_eval(a_regress_simple const *ctx, double val)
calculate predicted value for simple linear regression
void a_regress_simple_init(a_regress_simple *ctx, double coef, double bias)
initialize for simple linear regression
#define a_size
Definition a.h:610
instance structure for simple linear regression
Definition regress_simple.h:106