public List<Vector<double>> AddNoise(List<Vector<double>> points, double variance, int seed = 0) { List<Vector<double>> noisedPoints = new List<Vector<double>>(points.Count); int pointSize = points[0].Count; GaussianNoiseGenerator noise = new GaussianNoiseGenerator(); noise.Variance = variance; noise.Mean = 0.0; noise.RandomSeed = seed != 0; noise.Seed = seed; noise.UpdateDistribution(); for(int i = 0; i < _pointsCount; ++i) { Vector<double> cpoint = new DenseVector(pointSize); for(int p = 0; p < pointSize - 1; ++p) { cpoint[p] = points[i][p] + noise.GetSample(); } cpoint[pointSize - 1] = 1.0f; noisedPoints.Add(cpoint); } return noisedPoints; }
public List<CalibrationPoint> AddNoise(List<CalibrationPoint> points, double varReal, double varImg, int seed = 0) { List<CalibrationPoint> noisedPoints = new List<CalibrationPoint>(points.Count); GaussianNoiseGenerator noiseReal = new GaussianNoiseGenerator(); noiseReal.Variance = varReal; noiseReal.Mean = 0.0; noiseReal.RandomSeed = seed != 0; noiseReal.Seed = seed; noiseReal.UpdateDistribution(); GaussianNoiseGenerator noiseImage = new GaussianNoiseGenerator(); noiseImage.Variance = varImg; noiseImage.Mean = 0.0; noiseImage.RandomSeed = seed != 0; noiseImage.Seed = seed; noiseImage.UpdateDistribution(); for(int i = 0; i < _pointsCount; ++i) { CalibrationPoint cpoint = new CalibrationPoint(); cpoint.RealX = points[i].RealX + noiseReal.GetSample(); cpoint.RealY = points[i].RealY + noiseReal.GetSample(); cpoint.RealZ = points[i].RealZ + noiseReal.GetSample(); cpoint.ImgX = points[i].ImgX + noiseImage.GetSample(); cpoint.ImgY = points[i].ImgY + noiseImage.GetSample(); noisedPoints.Add(cpoint); } return noisedPoints; }
public Matrix<double> AddNoise(Matrix<double> matrix) { Matrix<double> noisedMat = matrix.Clone(); GaussianNoiseGenerator noise = new GaussianNoiseGenerator(); noise.Mean = 0.0; noise.RandomSeed = false; Random rand = new Random(_seed); for(int r = 0; r < noisedMat.RowCount; ++r) { for(int c = 0; c < noisedMat.ColumnCount; ++c) { noise.Seed = rand.Next(); noise.Variance = Math.Abs(noisedMat[r, c]) < 1e-12 ? 1e-12 : Math.Abs(noisedMat[r, c]) / 100.0; noise.UpdateDistribution(); noisedMat[r, c] = noisedMat[r, c] + noise.GetSample(); } } return noisedMat; }