证据权模型(C#版)

时间:2024-01-02 09:57:08

证据权法是通过计算和利用各种不同证据的权重(表示相对重要性)并将多种证据结合起来,预测某个时间是否会发生的一种方法

证据权法以概率论中的贝叶斯定理为基础。设D表示要一个随机事件。用P(D)表示这一事件概率,即D发生的概率。假设P(D)事先知道,即它是先验概率。则D不发生的概率为:

证据权模型(C#版)

定义: 证据权模型(C#版)

    称为事件D的几率(Odd Ratio),也称优势率,它能更好的表示事件D发生的可能性大小。

用集合 证据权模型(C#版)

表示与D有关的n个证据,并设Xj都是逻辑变量。用D|X表示"单元中存在X的情况下D发生"这一事件。用P(D|X)表示概率,也称为后验概率(后验概率是获得有关信息后对先验概率修正后的概率)。由贝叶斯定理:

证据权模型(C#版)

可以得出优势率:

证据权模型(C#版)

假设n个条件相互条件独立,并在两边同时去对数:

证据权模型(C#版)证据权模型(C#版)

令:

证据权模型(C#版)

证据权模型(C#版)

于是:

证据权模型(C#版)

事件D|X的几率为

证据权模型(C#版)

于是后验概率为:

证据权模型(C#版)

其中wi称为证据X的证据权,反应Xi的存在对D的重要性:

证据权模型(C#版)证据权模型(C#版)

其中,各条件概率的计算:

证据权模型(C#版)证据权模型(C#版)

定义:

证据权模型(C#版)

为X的对比系数,可以用来综合评价各证据的重要性

在数据较少的情况下,采用C来选择证据,回增大结果的不确定性,定义

证据权模型(C#版)

其中:证据权模型(C#版)为第i个证据后验概率的正负方差:

证据权模型(C#版)

  1.     /// <summary>
  2. /// 计算先验似然概率
  3. /// </summary>
  4. private void GetMinePriorLikelihoodProb()
  5. {
  6.     mineral_PriorProbability = sum_EvidenceCount[0] / (double)gridNumber;
  7.     minreal_PriorLiklihoodProbablity = mineral_PriorProbability / (1 - mineral_PriorProbability);
  8. }
  9. /// <summary>
  10.        /// 计算证据权参数
  11.        /// </summary>
  12.        private void GetEvidenceStatistc()
  13.        {
  14.            for (int i = 0; i < mineral_EvidenceCount - 1; i++)
  15.            {
  16.                //证据权正定义
  17.                /* Count(BjD)/Count(D)
  18.                 * ln----------------------
  19.                 * Count(Bj~D)/Count(~D)
  20.                 */
  21.                evidence_PosWeight[i] = Math.Log((sumEvidence_MineralOccur[i] / sum_EvidenceCount[0]) /
  22.                    ((sum_EvidenceCount[i + 1] - sumEvidence_MineralOccur[i]) / (gridNumber - sum_EvidenceCount[0])));
  23.                //证据权负定义
  24.                /* Count(~BjD)/Count(D)
  25.                 * ln-------------------------
  26.                 * Count(~Bj~D)/Count(~D)
  27.                 */
  28.                evidence_NegWeight[i] = Math.Log(((sum_EvidenceCount[0] - sumEvidence_MineralOccur[i]) / (sum_EvidenceCount[0]))
  29.                    / ((gridNumber - sum_EvidenceCount[0] - sum_EvidenceCount[i + 1] + sumEvidence_MineralOccur[i]) / (gridNumber - sum_EvidenceCount[0])));
  30.                //证据权正方差
  31.                /* 1 1
  32.                 * -----------+--------------
  33.                 * Count(BjD) Count(Bj~D)
  34.                 */
  35.                evidence_PosVariance[i] = (1 / sumEvidence_MineralOccur[i]) +
  36.                    (1 / (sum_EvidenceCount[i + 1] - sumEvidence_MineralOccur[i]));
  37.                //证据权负方差
  38.                /* 1 1
  39.                 * -----------+--------------
  40.                 * Count(~BjD) Count(~Bj~D)
  41.                 */
  42.                evidence_NegVariance[i] = (1 / (sum_EvidenceCount[0] - sumEvidence_MineralOccur[i])) +
  43.                    (1 / (gridNumber - sum_EvidenceCount[0] - sum_EvidenceCount[i + 1] + sumEvidence_MineralOccur[i]));
  44.                //对比度
  45.                //Cj=weightj+ - Weightj-
  46.                evidence_ContrastRatio[i] = evidence_PosWeight[i] - evidence_NegWeight[i];
  47.                //显著性统计量
  48.                //Stud(C)=Cj/s(c)
  49.                //s(c)=1/Sqrt(s2(weight+)+s2(weight-))
  50.                evidence_StatisticalSignficance[i] = evidence_ContrastRatio[i] /
  51.                    (Math.Sqrt(evidence_PosVariance[i] + evidence_NegVariance[i]));
  52.            }
  53.        }
  54. /// <summary>
  55.         /// 证据权合成
  56.         /// </summary>
  57.         private void SynthesisEvidence()
  58.         {
  59.             double[] evidence_PostProbLog = new double[gridNumber];
  60.             double[,] evidence_Data = (double[,])mineralAndEvidence.Clone();
  61.             for (int i = 1; i < mineral_EvidenceCount; i++)
  62.             {
  63.                 for (int j = 0; j < mineralAndEvidence.GetLength(1); j++)
  64.                 {
  65.                     //将复制证据图层中与对调
  66.                     if (evidence_Data[i, j] == 0)
  67.                     {
  68.                         evidence_Data[i, j] = 1;
  69.                     }
  70.                     else
  71.                     {
  72.                         evidence_Data[i, j] = 0;
  73.                     }
  74.                     evidence_PostProbLog[j] += evidence_Data[i, j] * evidence_NegWeight[i - 1] +
  75.                         mineralAndEvidence[i, j] * evidence_PosWeight[i - 1];
  76.                 }//for
  77.             }//for
  78.             GetPostProb(evidence_PostProbLog);
  79.         }//Method End
  80. /// <summary>
  81.         /// 计算后验概率
  82.         /// </summary>
  83.         /// <param name="postProbLog"></param>
  84.         private void GetPostProb(double[] postProbLog)
  85.         {
  86.             evidence_PostProb = new double[gridNumber];
  87.             for (int i = 0; i < postProbLog.Length; i++)
  88.             {
  89.                 evidence_PostProb[i] = (Math.Exp(postProbLog[i] + Math.Log(minreal_PriorLiklihoodProbablity)))
  90.                     / (1 + Math.Exp(postProbLog[i] + Math.Log(minreal_PriorLiklihoodProbablity)));
  91. }//for
  92.         }