我没有统计专家。但是......我会画出一个情节,比较每个点与另一个情节的等值点之间的差异,一次一个点。我将使用Math.Abs()将这10个差异中的每一个转换为一个正数,然后使用您希望的任何方法(平均值,中位数等)对10个差值取平均值。我会重复每个比较其他情节。大多数计算可以一路走开,您只需要保留每个图的平均数。最小的平均值可能是最接近匹配的情节。
因为我也不多了今天要做的事......
Dictionary<string, int[]> plots = new Dictionary<string, int[]>();
plots.Add("px1", new int[] { 90, 70, 100, 80, 60, 50, 70, 90, 75, 65 });
plots.Add("px2", new int[] { 5, 10, 15, 20, 25, 30, 18, 12, 20, 10 });
plots.Add("px3", new int[] { 15, 20, 15, 8, 3, 12, 28, 32, 12, 20 });
plots.Add("px4", new int[] { 20, 30, 10, 3, 5, 8, 24, 28, 15, 18 });
plots.Add("px5", new int[] { 60, 85, 32, 9, 15, 24, 70, 84, 45, 54 });
plots.Add("px6", new int[] { 10, 15, 18, 44, 12, 16, 25, 22, 16, 25 });
string test = "px4";
string winner = string.Empty;
double smallestAverage = double.MaxValue;
foreach (string key in plots.Keys)
{
if (key == test)
{
continue;
}
int[] a = plots[test];
int[] b = plots[key];
double count = 0;
for (int point = 0; point <= 9; point++)
{
count += Math.Abs(a[point] - b[point]);
}
double average = count/10;
if (average < smallestAverage)
{
smallestAverage = average;
winner = key;
}
}
Console.WriteLine("Winner: {0}", winner);
在一天结束时,答案取决于你为什么需要这样做。如果这是C#作业中的一些编程,那么使用任何旧方法可能都不错,但对不同方法的调查越多越好。但是,如果你需要这样做来分析政府医疗数据,那么你最好用某种统计学博士来聘用某人。 :-) – 2012-04-04 09:55:56