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

📄 hyperbolaregress.cs

📁 双曲线回归方程 HyperbolaRegress.cs 注意!该模型要求a与b的值要大于0!使用该模型时应注意验证这个限制条件。我在实现模型时未加入任何出错流程控制。X不能为0。 方程模型为
💻 CS
字号:
using System;

namespace InfieldForecast.ForecastModels
{
	/// <summary>
	/// HyperbolaRegress 的摘要说明。
	/// </summary>
	public class HyperbolaRegress : RegressFormulaStrategy
	{
		double[] reciprocalXArray;
		private LinearRegress linearRegress;
		public HyperbolaRegress(double[] xArray,double[] yArray)
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			this.xArray=xArray;
			this.yArray=yArray;
			init();
		}
		private void init()
		{
			reciprocalXArray=new double[getSize()];
			for(int i=0;i<xArray.Length;i++)
			{
				reciprocalXArray[i]=1/xArray[i];
			}
			this.linearRegress=new LinearRegress(reciprocalXArray,yArray);
		}
		public override double[] buildFormula()
		{
			double[] coefficient=this.linearRegress.buildFormula();
			reverseArray(coefficient);
			return coefficient;
		}
		private void reverseArray(double[] dataArray)
		{
			double temp=dataArray[0];
			dataArray[0]=dataArray[1];
			dataArray[1]=temp;
		}
		public override double computeR2()
		{
			return this.linearRegress.computeR2();
		}
		public override double computeR()
		{
			return Math.Sqrt(computeR2());
		}
		public override double forecast(double x)
		{
			double[] coefficientArray=getCoefficientArray();
			return coefficientArray[1]+coefficientArray[0]/x;
		}

		

	}
}

⌨️ 快捷键说明

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