/// <summary> /// 测试参数加权平差 /// </summary> public static void Test() { Random random = new Random();//观测噪声 double[][] A = MatrixUtil.CreateIdentity(6); double[][] L = MatrixUtil.Create(6, 1); for (int i = 0; i < L.Length; i++) { L[i][0] = i + 1 + random.NextDouble() - 0.5; } double[][] QL = MatrixUtil.CreateDiagonal(6, 1); double[][] Xa0 = MatrixUtil.Create(3, 1); for (int i = 0; i < Xa0.Length; i++) { Xa0[i][0] = i + 1; } double[][] Qx0 = MatrixUtil.CreateDiagonal(3, 0.001); // WeightedParamAdjustment adjust = new WeightedParamAdjustment(A, L, QL, Xa0, Qx0); }
/// <summary> /// 根据新的名称列表,生成新的矩阵。 /// </summary> /// <param name="newParamNames">新矩阵行列名称</param> /// <param name="DefaultValue">默认非对角线数值</param> /// <param name="DefaultDiagonalValue">默认对角线数值的平方根</param> /// <returns></returns> public double[][] GetNewMatrix(List <string> newParamNames, double defaultVal, double DefaultDiagonalValue) { int newLen = newParamNames.Count; double[][] newMatrix = MatrixUtil.CreateDiagonal(newLen, 0); for (int i = 0; i < newLen; i++) { string name = newParamNames[i]; NamedVector sat = null; if (dict.ContainsKey(name)) { sat = dict[name]; } else { sat = new NamedVector(name, defaultVal, DefaultDiagonalValue); } for (int j = 0; j < newLen; j++) { newMatrix[i][j] = sat.GetValue(newParamNames[j]); } } return(newMatrix); }
private WeightedVector BuildObservation() { var cova = MatrixUtil.CreateDiagonal(1, ObsValue.Variance); return(new WeightedVector(new double[] { ObsValue.Value }, cova)); }