示例#1
0
文件: linreg.go 项目: kofron/gogsl
/* ValueAt wraps gsl_fit_linear_est from gsl_fit.h.
 * A LinearFit can be interrogated for the value of a result at a particular
 * point x.  All of the parameters mentioned below are taken from the
 * LinearFit.
 * From the GSL manual:
 * This function uses the best-fit linear regression coefficients Y0, Slope
 * and their covariance Cov00, Cov01, Cov11 to compute the fitted function
 * y and its standard deviation y_err for the model
 * Y = Y0 + Slope* X at the point x.
 */
func (f *LinearFit) ValueAt(x float64) (y, y_err float64, e error) {
	er := C.gsl_fit_linear_est((C.double)(x),
		(C.double)(f.Y0),
		(C.double)(f.Slope),
		(C.double)(f.Cov00),
		(C.double)(f.Cov01),
		(C.double)(f.Cov11),
		(*C.double)(&y),
		(*C.double)(&y_err))
	if er != (C.int)(0) {
		e = gsl.NewGSLError((int)(er))
	}
	return
}
示例#2
0
文件: fit.go 项目: postfix/gsl-1
func LinearEst(x float64, c0 float64, c1 float64, cov00 float64, cov01 float64, cov11 float64) (int32, float64, float64) {
	var _outptr_6 C.double
	var _outptr_7 C.double
	_result := int32(C.gsl_fit_linear_est(C.double(x), C.double(c0), C.double(c1), C.double(cov00), C.double(cov01), C.double(cov11), &_outptr_6, &_outptr_7))
	return _result, *(*float64)(unsafe.Pointer(&_outptr_6)), *(*float64)(unsafe.Pointer(&_outptr_7))
}