Exemple #1
0
        public static double[] WeightedSplit(double Aggregate, List <double> samples, int NumBuildings)
        {
            if (NumBuildings < samples.Count)
            {
                throw new Exception("Number of buildings is lesser than size of multi-building sample vector!");
            }

            double[] WeightedSplit = new double[NumBuildings];

            double WeightedSum = Loss.WeightedSum(samples, NumBuildings);

            int TempNumBuildings = NumBuildings;
            int SamplesCount     = samples.Count;
            int i = 0;

            foreach (double SampledLossPerBuilding in samples)
            {
                int    NumBuildingsPerSample = (int)Math.Ceiling((double)TempNumBuildings / (double)SamplesCount--);
                double Split = Aggregate * (SampledLossPerBuilding / WeightedSum);
                for (int j = 0; j < NumBuildingsPerSample; j++)
                {
                    WeightedSplit[i + j] = Split;
                }
                i += NumBuildingsPerSample;
                TempNumBuildings -= NumBuildingsPerSample;
            }
            return(WeightedSplit);
        }
Exemple #2
0
 public void AddOrReplaceAmountByCOL(Loss loss)
 {
     foreach (var kv in loss.AmountByCOL)
     {
         if (!AmountByCOL.ContainsKey(kv.Key))
         {
             AmountByCOL.Add(kv.Key, kv.Value);
         }
         else
         {
             AmountByCOL[kv.Key] = AmountByCOL[kv.Key].Zip(kv.Value, (a, b) => a + b).ToList <double>();
         }
     }
 }
Exemple #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (this == obj)
            {
                return(true);
            }
            if (!(obj is Loss))
            {
                return(false);
            }
            Loss that = obj as Loss;

            return(Equals(this.AmountByCOL, that.AmountByCOL) &&
                   (this.Timestamp.Equals(that.Timestamp)) && (this.CausesOfLoss.Equals(that.CausesOfLoss)));
        }