2 回答

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個贊
Happy將年齡(或每個年齡)粘貼Status到列表中,然后計(jì)算標(biāo)準(zhǔn)偏差。本文作為確定標(biāo)準(zhǔn)偏差的良好過程:
所以像:
var happyAges = ctx.Men.Where(i=>i.status == "Happy")Select(i=>i.age);
var happySd = CalculateStdDev(happyAges);
此外,您可以將標(biāo)準(zhǔn)偏差方法設(shè)為靜態(tài),并使用擴(kuò)展方法在一個請求中完成所有操作。

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個贊
我這樣做了,它對我有用:
int?[] array = (from a in ctx.men where a.status == "Happy" select a.age).ToArray();
double? AVG = array.Average();
double? SumOfSquaresOfDifferences = array.Select(val => (val - AVG) * (val - AVG)).Sum();
double? SD = Math.Sqrt(Convert.ToDouble(SumOfSquaresOfDifferences) / array.Length);
- 2 回答
- 0 關(guān)注
- 123 瀏覽
添加回答
舉報