• 大小: 1.61M
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-10-30
  • 语言: 其他
  • 标签: 其他  

资源简介

WindowsFormsApplication1.rar

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Collections;
using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.Distributions;
namespace WindowsFormsApplication1
{
    public class DiscreteMarkov
    {
        #region 属性
        /// 
        /// 样本点状态时间序列按照时间升序
        /// 

        public List StateList { get; set; }
        /// 
        /// 状态总数对应模型的m
        /// 

        public int Count { get; set; }
        /// 
        /// 概率转移矩阵Pij
        /// 

        public List ProbMatrix { get; set; }
        /// 
        /// 各阶的自相关系数
        /// 

        public double[] Rk { get; set; }
        /// 
        /// 各阶的权重
        /// 

        public double[] Wk { get; set; }
        /// 
        /// 频数矩阵
        /// 

        public int[][] CountStatic { get; set; }
        /// 
        /// 目标序列是否满足“马氏性“
        /// 

        public Boolean IsMarkov { get; set; }
        /// 
        /// 滞时期,K
        /// 

        public int LagPeriod { get; set; }
        /// 
        /// 预测概率
        /// 

        public double[] PredictValue { get; set; }
        #endregion
        
        #region 构造函数

        public DiscreteMarkov(List data int count int K = 5)
        {
            this.StateList = data;
            this.LagPeriod = K;
            this.Count = count;
            this.CountStatic = StaticCount(data count);
            this.ProbMatrix = new List();
            var t0 = DenseMatrix.OfArray(StaticProbability(this.CountStatic));
            ProbMatrix.Add(t0);

            for (int i = 1; i < K; i++) //根据CK方程,计算各步的状态转移矩阵
            {
                var temp = ProbMatrix[i - 1] * t0;
                ProbMatrix.Add(temp);
            }
            IsMarkov = ValidateMarkov();
            if (IsMarkov)
            {
                CorrCoefficient();
                TimeWeight();
                PredictProb();
            }
            else
            {
                Console.WriteLine(“马氏性 检验失败无法进行下一步预测“);
            }
        }
        #endregion

        #region 验证
        /// 
        /// 验证是否满足马氏性默认的显著性水平是0.05,自由度25
        /// 

        /// 
        private Boolean ValidateMarkov()
        {
            //计算列和
            int[] cp1 = new int[Count];
            double gm = 0;
            try
            {
                int allcount = CountStatic.Select(n => n.Sum()).Sum();//总数

                for (int i = 0; i < Count; i++)
                {
                    for (int j = 0; j < Count; j++) cp1[i] += CountStatic[j][i];
                }
                double[] cp = cp1.Select(n => (double)n / (double)allcoun

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1041  2016-01-04 14:35  WindowsFormsApplication1\WindowsFormsApplication1.sln

    ..A..H.     46592  2017-06-25 13:07  WindowsFormsApplication1\WindowsFormsApplication1.v12.suo

     文件       7664  2016-01-05 16:07  WindowsFormsApplication1\WindowsFormsApplication1\DiscreteMarkov.cs

     文件        505  2016-01-04 14:35  WindowsFormsApplication1\WindowsFormsApplication1\Program.cs

     文件       4446  2016-01-04 15:09  WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj

     文件    1121752  2013-07-23 05:17  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\FSharp.Core.dll

     文件     603029  2013-07-23 05:17  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\FSharp.Core.xml

     文件    1177600  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.dll

     文件     455680  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.FSharp.dll

     文件     294400  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.FSharp.pdb

     文件      90418  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.FSharp.xml

     文件    3792384  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.pdb

     文件    3229256  2015-12-30 17:23  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\MathNet.Numerics.xml

     文件      19968  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      50688  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      22656  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2017-03-19 05:00  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件      36352  2013-09-24 22:54  WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\zh-Hans\FSharp.Core.resources.dll

     文件       1453  2016-01-05 16:22  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7214  2017-06-25 13:03  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       6555  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件      19968  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe

     文件        180  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources

     文件      50688  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb

     文件        180  2016-01-04 15:24  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件      48789  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache

     文件        977  2017-06-25 13:06  WindowsFormsApplication1\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件       1390  2016-01-04 14:35  WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2900  2016-01-04 14:35  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2016-01-04 14:35  WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx

............此处省略17个文件信息

评论

共有 条评论