public static FragilityCurve CalculateCombinedProbabilityFragilityCurve(HydraulicCondition[] conditions, CriticalPathElement[] treeEventCurves) { if (!CheckProbabilitiesAreEqual(conditions, treeEventCurves)) { throw new ArgumentOutOfRangeException(); } var curve = new FragilityCurve(); for (int i = 0; i < conditions.Length - 1; i++) { double waterLevelProbability = conditions[i].Probability; double nextWaterLevelProbability = conditions[i + 1].Probability; double estimatedCombinedProbability = CalculateConditionalProbability(conditions[i].WaterLevel, treeEventCurves); double nextEstimatedCombinedProbability = CalculateConditionalProbability(conditions[i + 1].WaterLevel, treeEventCurves); var m9 = (estimatedCombinedProbability - nextEstimatedCombinedProbability) / Math.Log(waterLevelProbability / nextWaterLevelProbability); var n9 = estimatedCombinedProbability - m9 * Math.Log(waterLevelProbability); var interpiolated = (Probability)((n9 * waterLevelProbability + m9 * (waterLevelProbability * Math.Log(waterLevelProbability) - waterLevelProbability)) - (n9 * nextWaterLevelProbability + m9 * (nextWaterLevelProbability * Math.Log(nextWaterLevelProbability) - nextWaterLevelProbability))); curve.Add(new FragilityCurveElement(conditions[i].WaterLevel, interpiolated)); } var lastCondition = conditions.Last(); curve.Add(new FragilityCurveElement(lastCondition.WaterLevel, lastCondition.Probability)); return(curve); }
public static FragilityCurve GetFragilityCurve(this TreeEvent treeEvent, IEnumerable <double> waterLevels) { switch (treeEvent.ProbabilitySpecificationType) { case ProbabilitySpecificationType.Classes: var classCurve = new FragilityCurve(); foreach (var waterLevel in waterLevels) { classCurve.Add(new FragilityCurveElement(waterLevel, GetClassesBasedProbabilityForWaterLevel(treeEvent, waterLevel))); } return(classCurve); case ProbabilitySpecificationType.FixedFreqeuncy: // TODO: Interpolate if necessary return(treeEvent.FixedFragilityCurve); case ProbabilitySpecificationType.FixedValue: var curve = new FragilityCurve(); foreach (var waterLevel in waterLevels) { curve.Add(new FragilityCurveElement(waterLevel, treeEvent.FixedProbability)); } return(curve); default: throw new NotImplementedException(); } }
public static FragilityCurve GetClassBasedLowerFragilityCurve(this TreeEvent treeEvent, IEnumerable <double> waterLevels) { var curve = new FragilityCurve(); foreach (var waterLevel in waterLevels) { curve.Add(new FragilityCurveElement(waterLevel, GetClassesBasedProbabilityForWaterLevel(treeEvent, waterLevel, e => e.MinEstimation))); } return(curve); }
public static FragilityCurve CalculateCombinedFragilityCurve(HydraulicCondition[] conditions, CriticalPathElement[] criticalPathElements) { if (!CheckProbabilitiesAreEqual(criticalPathElements)) { throw new ArgumentOutOfRangeException(); } var curve = new FragilityCurve(); foreach (var condition in conditions) { curve.Add(new FragilityCurveElement(condition.WaterLevel, CalculateConditionalProbability(condition.WaterLevel, criticalPathElements))); } return(curve); }