亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lsq.cpp

?? orange源碼 數據挖掘技術
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// TODO: CopyRight .. =???

#include <math.h>
#include "lsq.h"
//#include <malloc.h>

void xdisaster() {
}

void lsq::startup(int nvar, bool fit_const) {
/*
!     Allocates dimensions for arrays and initializes to zero
!     The calling program must set nvar = the number of variables, and
!     fit_const = true if a constant is to be included in the model,
!     otherwise fit_const = false
!
	!--------------------------------------------------------------------------*/
	
	int i;
	
	nobs = 0;
	if (fit_const) {
		ncol = nvar + 1;
	} else {
		ncol = nvar;
	}
	
	if (initialized) {
		free(d);
		free(rhs);
		free(r);
		free(tol);
		free(rss);
		free(vorder);
	}
	
	r_dim = ncol * (ncol - 1)/2;
	
	++ncol;
	++r_dim;
	d = (double*)malloc(sizeof(double)*ncol);
	rhs = (double*)malloc(sizeof(double)*ncol);
	tol = (double*)malloc(sizeof(double)*ncol);
	rss = (double*)malloc(sizeof(double)*ncol);
	vorder = (int*)malloc(sizeof(int)*ncol);
	r = (double*)malloc(sizeof(double)*r_dim);
	--ncol;
	--r_dim;
	
	for (i = 0; i <= ncol; ++i) {
		d[i] = zero;
		rhs[i] = zero;
	}
//nt tmpc=0;
	for (i = 0; i <= r_dim; ++i) {
/*		if (i%((ncol+ncol-tmpc)/2 + 1)==0) {
			tmpc++;
			r[i]=0.5;
		}
		else*/
			r[i] = zero;
	}
	sserr = zero;
	
	if (fit_const) {
		for (i = 1; i <= ncol; ++i) {
			vorder[i] = i-1;
		}
	} else { 	
		for (i = 1; i <= ncol; ++i) {
			vorder[i] = i;
		}
	}

	initialized = true;
	tol_set = false;
	rss_set = false;
}

void lsq::includ(double weight, double *xrow, double yelem) {
/*
!     ALGORITHM AS75.1  APPL. STATIST. (1974) VOL.23, NO. 3
!     Calling this routine updates D, R, RHS and SSERR by the
!     inclusion of xrow, yelem with the specified weight.
!     *** WARNING  Array XROW is overwritten.
!     N.B. As this routine will be called many times in most applications,
!          checks have been eliminated.
!
!--------------------------------------------------------------------------
	*/
	int i, k, nextr;
	double w, y, xi, di, wxi, dpi, cbar, sbar, xk;
	
	nobs = nobs + 1;
	w = weight;
	y = yelem;
	rss_set = false;
	nextr = 1;
	for (i = 1; i <= ncol; ++i) {
		//!     Skip unnecessary transformations.   Test on exact zeroes must be
		//!     used or stability can be destroyed.
		
		if (fabs(w) < vsmall)
			return;
		xi = xrow[i];
		if (fabs(xi) < vsmall)
			nextr = nextr + ncol - i;
		else {
			di = d[i];
			wxi = w * xi;
			dpi = di + wxi*xi;
			cbar = di / dpi;
			sbar = wxi / dpi;
			w = cbar * w;
			d[i] = dpi;
			for (k = i+1; k <= ncol; ++k) {
 				xk = xrow[k];
				xrow[k] = xk - xi * r[nextr];
				r[nextr] = cbar * r[nextr] + sbar * xk;
				nextr = nextr + 1;
			}
			xk = y;
			y = xk - xi * rhs[i];
			rhs[i] = cbar * rhs[i] + sbar * xk;
		}
	}
	
	//!     Y * sqrt(W) is now equal to the Brown, Durbin & Evans recursive
	//!     residual.
	
	sserr = sserr + w * y * y;
	
}


void lsq::regcf(double *beta, int nreq, int& ifault) {
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2
!     Modified version of AS75.4 to calculate regression coefficients
!     for the first NREQ variables, given an orthogonal reduction from
!     AS75.1.
!
!--------------------------------------------------------------------------
	*/
	int i, j, nextr;
	
	ifault = 0;
	if (nreq < 1 || nreq > ncol) 
		ifault = ifault + 4;
	if (ifault != 0) 
		return;
	
	if (!tol_set) 
		tolset();
	
	for (i = nreq; i >= 1; --i) {
		if (sqrt(d[i]) < tol[i]) {
			beta[i] = zero;
			d[i] = zero;
		} else {
			beta[i] = rhs[i];
			nextr = (i-1) * (ncol+ncol-i)/2 + 1;
			for(j = i+1; j <= nreq; ++j) {
				beta[i] -= r[nextr] * beta[j];
				nextr = nextr + 1;
			}
		}
	}
	
	return;
}




void lsq::tolset() {
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2

  !     Sets up array TOL for testing for zeroes in an orthogonal
  !     reduction formed using AS75.1.
	*/
	int col, row, pos,i;
	double eps, ten = 10.0, total, *work;
	
	work = new double[ncol+1];
	eps = .2220e-7;
	
	/*
	!     Set tol(i) = sum of absolute values in column I of R after
	!     scaling each element by the square root of its row multiplier,
	!     multiplied by EPS.
	*/
	
	for (i = 1; i <= ncol; ++i) {
		work[i] = sqrt(d[i]);
	}
	for(col = 1; col <= ncol; ++col) {
		pos = col - 1;
		total = work[col];
		for(row = 1; row < col; ++row) {
			total = total + fabs(r[pos]) * work[row];
			pos = pos + ncol - row - 1;
		}
		tol[col] = eps * total;
	}
	
	tol_set = true;
	delete[] work;
}



void lsq::sing(bool* lindep, int& ifault) {
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2
!     Checks for singularities, reports, and adjusts orthogonal
!     reductions produced by AS75.1.
!--------------------------------------------------------------------------
	*/
	
	double temp, *x, *work, y, weight;
	int col, pos, row, pos2,i,l;
	
	x = new double[ncol+1];
	work = new double[ncol+1];
	
	ifault = 0;

	if(!tol_set)
		tolset();
	
	for (i = 1; i <= ncol; ++i) {
		work[i] = sqrt(d[i]);
	}	
	for( col = 1; col <= ncol; ++col) {
		
	/*
	!     Set elements within R to zero if they are less than tol(col) in
	!     absolute value after being scaled by the square root of their row
	!     multiplier.
		*/
		
		temp = tol[col];
		pos = col - 1;
		for(row = 1; row <= col-1; ++row) {
			if (fabs(r[pos]) * work[row] < temp) 
				r[pos] = zero;
			pos = pos + ncol - row - 1;
		}
		/*
		!     If diagonal element is near zero, set it to zero, set appropriate
		!     element of LINDEP, and use INCLUD to augment the projections in
		!     the lower rows of the orthogonalization.
		*/
//		printf("%f %f\n",work[col],temp);
		lindep[col] = false;
		if (work[col] <= temp) {
			lindep[col] = true;
			ifault = ifault - 1;
			if (col < ncol) {
				pos2 = pos + ncol - col + 1;
				for(l = 1; l <= ncol; ++l) {
					x[l] = zero;
				}
				for(l = col+1; l <= ncol; ++l) {
					x[l] = r[pos+l-col];
				}
				y = rhs[col];
				weight = d[col];
				for(l = pos+1; l <= pos2-1; ++l) {
					r[l] = zero;
				}
				d[col] = zero;
				rhs[col] = zero;
				includ(weight, x, y);
				nobs--;
			}
			else
				sserr = sserr + d[col] * rhs[col]*rhs[col];
		}
	}
	
	delete[] x;
	delete[] work;
	return;
}


void lsq::ss() {
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2
!     Calculates partial residual sums of squares from an orthogonal
!     reduction from AS75.1.
!
!--------------------------------------------------------------------------
	*/
	
	int i;
	double total;
	
	total = sserr;
	rss[ncol] = sserr;
	for (i = ncol; i >= 2; --i) {
		total = total + d[i] * rhs[i]*rhs[i];
		rss[i-1] = total;
	}
	rss_set = false;
	return;
}

void lsq::cov(int nreq, double& var, double *covmat, int dimcov, double *sterr, int& ifault) {
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2
!     Calculate covariance matrix for regression coefficients for the
!     first nreq variables, from an orthogonal reduction produced from
!     AS75.1.
	*/
	
	int dim_rinv, pos, row, start, pos2, col, pos1, k;
	double total;
	double *rinv;
	
	//!     Check that dimension of array covmat is adequate.
	
	if (dimcov < nreq*(nreq+1)/2) {
		ifault = 1;
		return;
	}

	if (!rss_set)
		ss();

	
	//!     Check for small or zero multipliers on the diagonal.
	
	ifault = 0;
	for (row = 1;row<= nreq; ++row) {
		if (fabs(d[row]) < vsmall) 
			ifault = -row;
	}
	if (ifault != 0) 
		return;
	
	//!     Calculate estimate of the residual variance.
	
	if (nobs > nreq) 
		var = rss[nreq] / (nobs - nreq);
	else {
		ifault = 2;
		return;
	}
	
	dim_rinv = nreq*(nreq-1)/2;

	rinv = (double *)malloc(sizeof(double)*(dim_rinv+1));	

	inv(nreq, rinv);
	pos = 1;
	start = 1;
	for(row = 1; row <= nreq; ++row) {
		pos2 = start;
		for(col = row; col <= nreq; ++col) {
			pos1 = start + col - row;
			if (row == col) 
				total = one / d[col];
			else
				total = rinv[pos1-1] / d[col];
			
			for(k = col+1; k <= nreq; ++k) {
				total = total + rinv[pos1] * rinv[pos2] / d[k];
				pos1 = pos1 + 1;
				pos2 = pos2 + 1;
			}
			covmat[pos] = total * var;
			if (row == col)
				sterr[row] = sqrt(covmat[pos]);
			pos = pos + 1;
		}
		start = start + nreq - row;
	}
	free(rinv);
	return;
}


void lsq::inv(int nreq, double *rinv) {
	
/*
!     ALGORITHM AS274  APPL. STATIST. (1992) VOL.41, NO. 2
!     Invert first nreq rows and columns of Cholesky factorization
!     produced by AS 75.1.
!
!--------------------------------------------------------------------------
	*/
	
	int pos, row, col, start, k, pos1, pos2;
	double total;
	
	//!     Invert R ignoring row multipliers, from the bottom up.
	
	pos = nreq * (nreq-1)/2;
	for (row = nreq-1; row >=  1; row--) {
		start = (row-1) * (ncol+ncol-row)/2 + 1;
		for (col = nreq; col >= row+1; col--) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野结衣精品在线| 成人精品鲁一区一区二区| 色综合天天综合网天天看片| 国产色综合一区| 中文字幕不卡三区| 国产精品一线二线三线| 久久日一线二线三线suv| 狠狠色伊人亚洲综合成人| 欧美精品一区二区三区蜜臀| 国产成人精品亚洲午夜麻豆| 国产精品久久三| 欧美天堂一区二区三区| 免播放器亚洲一区| 欧美韩国一区二区| 欧美三级中文字| 精品一区二区在线播放| 国产午夜一区二区三区| 国产精品亚洲人在线观看| 国产精品美女久久久久aⅴ| 欧美伊人久久大香线蕉综合69 | 色综合天天综合网国产成人综合天| 一区二区三区在线高清| 91精品国产福利| 国产精品一区二区三区99| 亚洲色欲色欲www| 日韩欧美高清dvd碟片| 在线免费观看不卡av| 石原莉奈一区二区三区在线观看| 日韩亚洲欧美在线| 99视频在线精品| 日本中文字幕一区| 国产精品免费视频一区| 欧美日韩和欧美的一区二区| 国产美女在线观看一区| 亚洲国产一区二区三区青草影视| 久久在线观看免费| 91久久精品网| 国产精品一区二区在线观看不卡| 国产精品国产精品国产专区不蜜| 欧美日韩另类国产亚洲欧美一级| 大美女一区二区三区| 亚洲综合色噜噜狠狠| 精品久久人人做人人爱| 一本到不卡免费一区二区| 精品一区二区三区免费毛片爱 | 亚洲午夜视频在线观看| 久久综合色之久久综合| 欧美性大战久久久久久久| 国产成人精品三级| 美女任你摸久久| 国产精品福利一区二区| 日韩欧美国产综合一区| 欧美色图12p| www.成人网.com| 国产乱子伦视频一区二区三区| 亚洲国产成人精品视频| 国产精品欧美久久久久无广告 | 亚洲精品在线网站| 欧美三级电影网站| 色天天综合色天天久久| 国产suv精品一区二区883| 麻豆国产精品视频| 视频在线观看一区二区三区| 一区二区不卡在线视频 午夜欧美不卡在 | 亚洲综合在线第一页| 久久久久久亚洲综合| 日韩精品在线网站| 欧美中文字幕一二三区视频| 99久久久精品| 99久久综合国产精品| 狠狠色狠狠色合久久伊人| 日韩av电影天堂| 一区二区三区精品| ...中文天堂在线一区| 国产女同性恋一区二区| 精品捆绑美女sm三区| 欧美一区三区二区| 欧美日韩一区三区| 色综合天天综合网天天看片| 丁香婷婷综合激情五月色| 国产一本一道久久香蕉| 国产精品一二三| 捆绑调教一区二区三区| 天堂va蜜桃一区二区三区漫画版| 亚洲六月丁香色婷婷综合久久 | 国产精品网站在线| 中文字幕一区三区| 一区二区中文字幕在线| 自拍偷拍国产精品| 亚洲影视在线播放| 日本va欧美va精品发布| 久草热8精品视频在线观看| 裸体歌舞表演一区二区| 国产做a爰片久久毛片| 国产99精品在线观看| www.爱久久.com| 欧美色中文字幕| 欧美老肥妇做.爰bbww| 日韩欧美美女一区二区三区| 337p日本欧洲亚洲大胆精品| 国产欧美一区二区三区鸳鸯浴| 久久婷婷国产综合精品青草| 国产精品久久久久婷婷二区次| 亚洲伦理在线免费看| 日本欧美在线看| 国产aⅴ综合色| 欧美日韩久久久一区| www成人在线观看| 亚洲天堂2014| 免费人成精品欧美精品| 国产成人精品综合在线观看 | 91在线码无精品| 欧美私模裸体表演在线观看| 日韩一区二区三区视频在线| 国产日韩欧美精品一区| 亚洲综合色丁香婷婷六月图片| 日本vs亚洲vs韩国一区三区二区| 成人免费毛片嘿嘿连载视频| 在线区一区二视频| 国产亚洲一区字幕| 亚洲成人一区在线| 捆绑调教美女网站视频一区| 成人午夜免费电影| 色综合久久久久久久| 欧美日韩1区2区| 26uuu久久天堂性欧美| 亚洲精品在线一区二区| 亚洲色图视频网| 日韩和欧美一区二区| 麻豆精品久久久| 国产精品一卡二| 日本电影欧美片| 精品国产自在久精品国产| 亚洲欧美国产毛片在线| 日本亚洲天堂网| fc2成人免费人成在线观看播放 | 国产成人精品三级| 亚洲欧洲韩国日本视频| 成人视屏免费看| 欧美一区二区三区不卡| 日韩欧美二区三区| 亚洲色图一区二区| 一区二区三区美女| 久久 天天综合| 欧美精品九九99久久| 国产日产亚洲精品系列| 美国毛片一区二区三区| 国模娜娜一区二区三区| 欧美日韩日日摸| 亚洲精品国产无套在线观| 免费观看久久久4p| 欧洲色大大久久| 久久精品人人做人人综合| 日本不卡不码高清免费观看| 大尺度一区二区| 日韩视频免费观看高清完整版| 国产精品全国免费观看高清 | 精品日本一线二线三线不卡| 亚洲啪啪综合av一区二区三区| 国产乱人伦偷精品视频不卡| 欧美日韩免费不卡视频一区二区三区| 久久久五月婷婷| 久久精品国产亚洲a| 欧美一区二区美女| 中文字幕中文字幕一区二区| 秋霞电影一区二区| 欧美肥妇毛茸茸| 亚洲午夜av在线| 欧美四级电影在线观看| 中文字幕一区二区不卡 | 亚洲日韩欧美一区二区在线| 国产剧情一区二区三区| 精品国产sm最大网站免费看| 亚洲成在线观看| 日韩一区二区免费视频| 日韩1区2区3区| 欧美精品在线观看播放| 免费成人深夜小野草| 欧美一区国产二区| 国产伦精品一区二区三区视频青涩| 欧美精品乱码久久久久久 | 中文字幕一区二区三区av| 国产高清不卡二三区| 精品精品国产高清a毛片牛牛| 美女视频网站黄色亚洲| 欧美午夜一区二区三区免费大片| 一区二区免费看| 欧美一区二区视频免费观看| 日本不卡123| 国产精品美女久久久久aⅴ| 另类人妖一区二区av| 欧美激情艳妇裸体舞| 日本高清无吗v一区| 婷婷久久综合九色综合绿巨人| 精品人在线二区三区| 国产ts人妖一区二区| 亚洲一区二区黄色| 欧美色综合网站| 精品无人码麻豆乱码1区2区| 国产精品国产自产拍高清av |