Fund.TMarginalRun.WriteSummaryDamage C# (CSharp) Method

WriteSummaryDamage() public method

public WriteSummaryDamage ( int WeightingschemeId, double bgDamage, IEnumerable damages, WeightingCombination WeightingCombinations ) : void
WeightingschemeId int
bgDamage double
damages IEnumerable
WeightingCombinations WeightingCombination
return void
        public void WriteSummaryDamage(int WeightingschemeId, double bgDamage, IEnumerable<double> damages, WeightingCombination[] WeightingCombinations)
        {
            if (SummaryCsv != null)
            {
                int gas = (int)_gas;

                var stats = new DescriptiveStatistics(damages);

                var sortedDamages = damages.OrderBy(i => i).ToArray();

                double count = sortedDamages.Length;

                int skiptake0_001 = (int)(count * 0.001 / 2.0);
                int skiptake0_01 = (int)(count * 0.01 / 2.0);
                int skiptake0_05 = (int)(count * 0.05 / 2.0);

                var trimmedMean0_001 = sortedDamages.Skip(skiptake0_001).Take(sortedDamages.Length - 2 * skiptake0_001).Mean();

                var trimmedMean0_01 = sortedDamages.Skip(skiptake0_01).Take(sortedDamages.Length - 2 * skiptake0_01).Mean();

                var trimmedMean0_05 = sortedDamages.Skip(skiptake0_05).Take(sortedDamages.Length - 2 * skiptake0_05).Mean();

                SummaryCsv.WriteLine("{0};{1};{2};{3};{4:f15};{5:f15};{6:f15};{7:f15};{8:f15};{9:f15};{10:f15};{11:f15};{12:f15};{13:f15};{14:f15};{15:f15};{16:f15}",
                    OutputVerbal ? ScenarioName : ScenarioId.ToString(),
                    OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString(),
                    _emissionyear,
                    OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString(),
                    bgDamage,
                    stats.Mean,
                    trimmedMean0_001,
                    trimmedMean0_01,
                    trimmedMean0_05,
                    stats.Median,
                    stats.StandardDeviation,
                    stats.Variance,
                    stats.Skewness,
                    stats.Kurtosis,
                    stats.Minimum,
                    stats.Maximum,
                    Math.Sqrt(stats.Variance) / Math.Sqrt(stats.Count)
                    );

            }
        }