create regress_simple for Java
[liba.git] / java / src / liba / regress_simple.java
blob146a4228f58d01403043f7e47fab2cd37a2830ed
1 package liba;
3 import java.nio.ByteBuffer;
5 /** simple linear regression */
6 public class regress_simple {
7 ByteBuffer ctx;
8 static {
9 System.loadLibrary("a");
10 clinit();
13 static final native void clinit();
15 final native void init(double coef, double bias);
17 /**
18 * construct a new {@link regress_simple} object
20 * @param coef regression coefficient
21 * @param bias intercept
23 public regress_simple(double coef, double bias) {
24 init(coef, bias);
27 /**
28 * get regression coefficient for simple linear regression
30 * @return regression coefficient
32 public final native double coef();
34 /**
35 * set regression coefficient for simple linear regression
37 * @param coef regression coefficient
38 * @return {@link regress_simple}
40 public final native regress_simple set_coef(double coef);
42 /**
43 * get intercept for simple linear regression
45 * @return intercept
47 public final native double bias();
49 /**
50 * set intercept for simple linear regression
52 * @param bias intercept
53 * @return {@link regress_simple}
55 public final native regress_simple set_bias(double bias);
57 /**
58 * calculate predicted value for simple linear regression
60 * @param val independent variable
61 * @return predicted value
63 public final native double eval(double val);
65 /**
66 * calculate predicted value for simple linear regression
68 * @param val dependent variable
69 * @return predicted value
71 public final native double evar(double val);
73 /**
74 * calculate predicted value for simple linear regression
76 * @param x predictor data, specified as a numeric matrix
77 * @param y response data, specified as a numeric vector
78 * @param x_mean mean of predictor data
79 * @param y_mean mean of response data
80 * @return {@link regress_simple}
82 public final native regress_simple ols_(double[] x, double[] y, double x_mean, double y_mean);
84 /**
85 * calculate predicted value for simple linear regression
87 * @param x predictor data, specified as a numeric matrix
88 * @param y response data, specified as a numeric vector
89 * @param x_mean mean of predictor data
90 * @return {@link regress_simple}
92 public final native regress_simple olsx(double[] x, double[] y, double x_mean);
94 /**
95 * calculate predicted value for simple linear regression
97 * @param x predictor data, specified as a numeric matrix
98 * @param y response data, specified as a numeric vector
99 * @param y_mean mean of response data
100 * @return {@link regress_simple}
102 public final native regress_simple olsy(double[] x, double[] y, double y_mean);
105 * calculate predicted value for simple linear regression
107 * @param x predictor data, specified as a numeric matrix
108 * @param y response data, specified as a numeric vector
109 * @return {@link regress_simple}
111 public final native regress_simple ols(double[] x, double[] y);
114 * zeroing for simple linear regression
116 * @return {@link regress_simple}
118 public final native regress_simple zero();