/// <summary> /// 给轨迹点添加泊松噪音 /// </summary> /// <param name="points">轨迹点</param> /// <param name="lambda">泊松分布中的lambda</param> /// <param name="XMax">X坐标轴的最大值</param> /// <param name="YMax">y坐标轴的最大值</param> /// <returns>添加噪音后的轨迹点</returns> public static PointD[] addPoissonNoise(PointD[] points,int XMax,int YMax) { PointD[] noisePoint = new PointD[points.Length]; double lambdaX = 0; double lambdaY = 0; foreach (PointD point in points) { lambdaX += point.X; lambdaY += point.Y; } lambdaX /= points.Length; lambdaY /= points.Length; for (int i = 0; i < points.Length;i++ ) { // MessageBox.Show(""+XMax); noisePoint[i] = new PointD(); //防止坐标超过雷达的范围 noisePoint[i].X = ((points[i].X + GetPoisson(lambdaX)) > XMax) ? XMax : points[i].X + GetPoisson(lambdaX); noisePoint[i].Y = ((points[i].Y + GetPoisson(lambdaY)) > YMax) ? YMax : points[i].Y + GetPoisson(lambdaY); } return noisePoint; }
/// <summary> /// 给轨迹添加高斯噪声 /// </summary> /// <param name="points">轨迹中的点</param> /// <param name="mean">均值</param> /// <param name="variance">方差</param> /// <returns>添加高斯噪音后的轨迹点</returns> public static PointD[] addGuassianNoise(PointD[] points,double XMean,double XVariance,double YMean,double YVariance) { PointD[] noisePoint = new PointD[points.Length]; //添加高斯噪音,x 和 y for (int i = 0; i < points.Length;i++ ) { noisePoint[i] = new PointD(); double factor1 = rand.NextDouble(); double factor2 = rand.NextDouble(); //rand normal(0,1) double randStdNormal = Math.Sqrt(-2.0*Math.Log(factor1))*Math.Sin(2.0*Math.PI*factor2); //rand normal(mean,variance^2) double randNormalX = XMean+XVariance*randStdNormal; double randNormalY = YMean + YVariance * randStdNormal; noisePoint[i].X = points[i].X + randNormalX; noisePoint[i].Y = points[i].Y + randNormalY; } return noisePoint; }
/// <summary> /// 给轨迹点添加均匀噪音 /// </summary> /// <param name="points">原始轨迹点</param> /// <returns>添加噪音后的轨迹点</returns> public static PointD[] addUniformNoise(PointD[] points,double XA,double XB,double YA,double YB) { PointD[] noisePoint = new PointD[points.Length]; Random r; for (int i = 0; i < points.Length; i++) { r = new Random(); noisePoint[i] = new PointD(); noisePoint[i].X = points[i].X + rand.Next((int)XA,(int)XB); noisePoint[i].Y = points[i].Y + rand.Next((int)YA,(int)YB); } return noisePoint; }
public static Complex transferToComplex(PointD p) { return new Complex(p.X, p.Y); }
/** * 特性分析处理类,这里面添加特性处理的代码 * param: list 是运行轨迹的一些点; count 是特性的个数 * */ public Dictionary<String, double> getTimeAndSpaceFeature(List<PointD> list,int count) { Dictionary<String, double> featDic = new Dictionary<String, double>(); //计算时域空域特征分析 double[] features = new double[count]; PointD[] p1 = new PointD[list.Count]; for (int i = 0; i < list.Count; i++) { p1[i] = list[i]; } double[] pX = new double[list.Count]; for (int i = 0; i < list.Count; i++) { pX[i] = p1[i].X; } //算术平均值,arithmetic mean value for (int i = 0; i < list.Count; i++) { features[0] += p1[i].X; } features[0] /= list.Count; featDic.Add("算术平均值", features[0]); //几何平均值,geometric mean features[1] = 1.0; for (int i = 0; i < list.Count; i++) { if (p1[i].X != 0) features[1] *= p1[i].X; } features[1] = Math.Pow(features[1], 1 / list.Count); featDic.Add("几何平均值", features[1]); //均方根值,root mean square value for (int i = 0; i < list.Count; i++) { features[2] += Math.Pow(p1[i].X, 2); } features[2] /= list.Count; features[2] = Math.Pow(features[2], 1 / 2); featDic.Add("均方根值", features[2]); //方差, variance for (int i = 0; i < list.Count; i++) { features[3] += Math.Pow(p1[i].X - features[0], 2); } features[3] /= list.Count - 1; featDic.Add("方差", features[3]); //标准差,standard deviation for (int i = 0; i < list.Count; i++) { features[4] += Math.Pow(p1[i].X - features[0], 2); } features[4] /= list.Count; features[4] = Math.Pow(features[4], 1 / 2); featDic.Add("标准差", features[4]); //波形指标,waveform indicators features[5] = featDic["均方根值"] / Math.Abs(featDic["算术平均值"]); featDic.Add("波形指标", features[5]); //峰值指标,peak index features[6] = pX.Max() / featDic["均方根值"]; featDic["峰值指标"] = features[6]; //脉冲指标,pulse factor features[7] = pX.Max() / Math.Abs(featDic["算术平均值"]); featDic["脉冲指标"] = features[7]; //方根幅值,root amplitude for (int i = 0; i < list.Count; i++) { features[8] += Math.Pow(Math.Abs(p1[i].X), 1 / 2); } features[8] = Math.Pow(features[8] / list.Count, 2); featDic["方根幅值"] = features[8]; //裕度指标,margin indicator features[9] = pX.Max() / featDic["方根幅值"]; featDic["裕度指标"] = features[9]; //峭度指标,Kurosis amplitude for (int i = 0; i < list.Count; i++) { features[10] += Math.Pow(p1[i].X, 4); } features[10] /= list.Count; features[10] = features[10] / Math.Pow(featDic["均方根值"], 4); featDic["峭度指标"] = features[10]; //自相关函数,m=2,autocorrelation for (int i = 0; i < (list.Count - 2); i++) { features[11] += p1[i].X * p1[i + 2].X; } featDic["自相关函数"] = features[11]; //互相关函数,cross-correlation for (int i = 0; i < (list.Count - 2); i++) { features[12] += p1[i].X * p1[i + 2].Y; } featDic["互相关函数"] = features[12]; return featDic; }