【发布时间】:2011-03-10 04:10:09
【问题描述】:
我是一个 c# 菜鸟,但我真的需要专业人士的帮助。我正在为一个项目使用 Visual Studio 2005,所以我没有 math.linq 我需要计算通用对象列表的标准偏差。该列表仅包含一个浮点数列表,没有什么太复杂的。但是我以前从来没有这样做过,所以我需要有人告诉我以前计算过通用列表的标准偏差。这是我尝试开始的代码:
//this is my list of objects inside. The valve data just contains a bunch of floats.
public class ValveDataResults
{
private List<ValveData> m_ValveResults;
public void AddValveData(ValveData valve)
{
m_ValveResults.Add(valve);
}
//this is the function where the standard deviation needs to be calculated:
public float LatchTimeStdev()
{
//below this is a working example of how to get an average or mean
//of same list and same "LatchTime" that needs to be calculated here as well.
}
//function to calculate average of latch time, can be copied for above st dev.
public float LatchTimeMean()
{
float returnValue = 0;
foreach (ValveData value in m_ValveResults)
{
returnValue += value.LatchTime;
}
returnValue = (returnValue / m_ValveResults.Count) * 0.02f;
return returnValue;
}
}
“Latch Time”是插入到 m_ValveResults 列表中的“ValveData”对象的浮点对象。
就是这样。任何帮助将不胜感激。谢谢
【问题讨论】:
-
欢迎来到 Stackoverflow。您有一个很好的问题,但为了将来参考,“PLZ HELP!!??@11”不是一个好的问题标题。
-
你为什么要接受this answer然后再问同样的问题?
-
@John - 我注意到在这个问题中他指定他正在使用 VS 2005。所以他将无法使用 Linq。
-
@Greg:那么他应该不接受该答案并修改该问题以禁止 linq。
标签: c# math visual-studio-2005 statistics