资源简介
实现了包括GM(1,1),线性回归预测,移动平均法等预测方法
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace 铁路运量预测及改扩建辅助程序
{
class Forecast
{
//data有二列,第一列表示x值,第二列表示y值
//一元线性回归分析预测返回相关系数
public static double LinearRegression(double[] dataout double Aout double B)
{
double[] derivedData = new double[data.GetLength(0) + 1 data.GetLength(1) + 3];
for (int i = 0; i < data.GetLength(0); i++)
{
derivedData[i 0] = data[i 0]; //X
derivedData[i 1] = data[i 1]; //Y
derivedData[i 2] = data[i 0] * data[i 1]; //XY
derivedData[i 3] = data[i 0] * data[i 0]; //XX
derivedData[i 4] = data[i 1] * data[i 1]; //YY
derivedData[derivedData.GetLength(0) - 1 0] += derivedData[i 0]; //X的累加
derivedData[derivedData.GetLength(0) - 1 1] += derivedData[i 1]; //Y的累加
derivedData[derivedData.GetLength(0) - 1 2] += derivedData[i 2]; //XY的累加
derivedData[derivedData.GetLength(0) - 1 3] += derivedData[i 3]; //XX的累加
derivedData[derivedData.GetLength(0) - 1 4] += derivedData[i 4]; //YY的累加
}
double xba = derivedData[derivedData.GetLength(0) - 1 0] / data.GetLength(0);
double yba = derivedData[derivedData.GetLength(0) - 1 1] / data.GetLength(0);
double Lxx = derivedData[derivedData.GetLength(0) - 1 3] - Math.Pow(derivedData[derivedData.GetLength(0) - 1 0] 2) / data.GetLength(0);
double Lyy = derivedData[derivedData.GetLength(0) - 1 4] - Math.Pow(derivedData[derivedData.GetLength(0) - 1 1] 2) / data.GetLength(0);
double Lxy = derivedData[derivedData.GetLength(0) - 1 2] - derivedData[derivedData.GetLength(0) - 1 0] * derivedData[derivedData.GetLength(0) - 1 1] / data.GetLength(0);
double b = Lxy / Lxx;
double a = yba - b * xba;
A = a;
B = b;
return Lxy / Math.Sqrt(Lxx * Lyy);
}
public static double LinearRegression(double[] data double x out double r)
{
double a;
double b;
r = LinearRegression(data out a out b);
return a + b * x;
}
//幂回归分析预测
public static double PowerRegression(double[] data out double A out double B)
{
double[] derivedData = (double[])data.Clone();
for (int i = 0; i < derivedData.GetLength(0); i++)
{
for (int j = 0; j < derivedData.GetLength(1); j++)
{
derivedData[i j] = Math.Log(derivedData[i j]);
}
}
double a;
double b;
double r;
r = LinearRegression(derivedData out a out b);
A = Math.Exp(a);
B = b;
- 上一篇:ASP.NET设计的博客网站
- 下一篇:用asp.net做的在线考试系统
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论