using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
float[] testArray = { 202.3F, 207.6F, 200.9F, 195.7F, 203.4F };
var result = StDev(testArray);
var result2 = 202;
var result3=(result / result2)*100;
Console.WriteLine(result3);
Console.ReadLine();
}
static float StDev(float[] arrData) //计算标准偏差
{
float xSum = 0F;
float xAvg = 0F;
float sSum = 0F;
float tmpStDev = 0F;
int arrNum = arrData.Length;
for (int i = 0; i < arrNum; i++)
{
xSum += arrData[i];
}
xAvg = xSum / arrNum;
for (int j = 0; j < arrNum; j++)
{
sSum += ((arrData[j] - xAvg) * (arrData[j] - xAvg));
}
tmpStDev = Convert.ToSingle(Math.Sqrt((sSum / (arrNum - 1))).ToString());
return tmpStDev;
}
}
}