我正在生成一個模型列表,模擬每分鐘收集一天的數據。我想創建一些隨機刪除一些數據點的其他模型。有沒有一種方法來實現這種行爲?下面是我的代碼隨機刪除數據點
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MathNet.Numerics;
using MathNet.Numerics.Statistics;
public void dataGenerator()
{
int hrs = 24;
int minutes = 60;
int samplesize = hrs * minutes; // this is one day worth of data, with data created every minute
double mean = 50;
double stdev = 1;
int maxmodel = 10;
List<double[]> models = new List<double[]>();
List<double> modelaverage = new List<double>();
List<double> modelvariance = new List<double>();
// generating normal models with different mean/deviations
for (int i = 1; i <= maxmodel; i++)
{
//deviations are incremented by i, to create modles of different deviations, with every model having a different center by 2*i
double[] model = Generate.Normal(samplesize, mean + 2*i, stdev * i);
models.Add(model);
modelaverage.Add(model.Average());
modelvariance.Add(model.Variance());
}
}
只需在0和'models.Length'之間生成一些隨機索引,刪除索引處的項? –
你需要隨機程度如何? – hoodaticus
@hoodaticus說我希望每個觀察都有相同的機會被刪除。換句話說,每個小時*分鐘(1440個觀測值)有50%的機會被移除 – syang