⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logarithmregress.cs

📁 对数回归方程 LogarithmRegress.cs 方程模型为 Y=a*LnX+b public override double[] buildFormula() 得到系数数组
💻 CS
字号:
using System;

namespace InfieldForecast.ForecastModels
{
	/// <summary>
	/// LogarithmRegress 的摘要说明。
	/// </summary>
	public class LogarithmRegress:RegressFormulaStrategy
	{
		private double[] lnXArray;
		private LinearRegress linearRegress;
		public LogarithmRegress(double[] xArray,double[] yArray)
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			this.xArray=xArray;
			this.yArray=yArray;
			init();
		}
		private void init()
		{
			lnXArray=new double[getSize()];
			for(int i=0;i<getSize();i++)
			{
				lnXArray[i]=Math.Log(xArray[i],Math.E);
			}
			linearRegress=new LinearRegress(lnXArray,yArray);
		}
		public override double[] buildFormula()
		{
			return linearRegress.getCoefficientArray();

		}
		public override double computeR2()
		{
			return linearRegress.computeR2();
		}
		public override double computeR()
		{
			return Math.Sqrt(computeR2());	
		}
		public override double forecast(double x)
		{
			return linearRegress.forecast(Math.Log(x,Math.E));
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -