def compute_probability(self, total_fatalities): """Pager method compute probaility of fatality in each magnitude bin. [0, 10), [10,10^2), [10^2,10^3), [10^3, 10^4), [10^4, 10^5), [10^5,) :param total_fatalities: List of total fatalities in each MMI class. :type total_fatalities: int, float :returns: Probability of fatality magnitude bin from lognorm.cdf(bin, shape=Zeta, scale=total_fatalities) :rtype: list(float) """ zeta = self.hardcoded_parameters['Zeta'] magnitude_bin = self.hardcoded_parameters['magnitude_bin'] cprob = numpy.ones_like(magnitude_bin, dtype=float) if total_fatalities > 1: cprob = log_normal_cdf(magnitude_bin, median=total_fatalities, sigma=zeta) cprob = numpy.append(cprob, 1.0) prob = numpy.hstack((cprob[0], numpy.diff(cprob))) * 100.0 return self.round_to_sum(prob)
def compute_fatality_rate(self): """Pager method to compute fatality rate. :returns: Fatality rate calculated as: lognorm.cdf(mmi, shape=Beta, scale=Theta) :rtype: dic """ mmi_range = self.hardcoded_parameters['mmi_range'] theta = self.hardcoded_parameters['Theta'] beta = self.hardcoded_parameters['Beta'] fatality_rate = {mmi: 0 if mmi < 4 else log_normal_cdf( mmi, median=theta, sigma=beta) for mmi in mmi_range} return fatality_rate
def compute_probability(self, total_fatalities): """Pager method compute probaility of fatality in each magnitude bin. [0, 10), [10,10^2), [10^2,10^3), [10^3, 10^4), [10^4, 10^5), [10^5,) :param total_fatalities: List of total fatalities in each MMI class. :type total_fatalities: int, float :returns: Probability of fatality magnitude bin from lognorm.cdf(bin, shape=Zeta, scale=total_fatalities) :rtype: list(float) """ zeta = self.hardcoded_parameters['Zeta'] magnitude_bin = self.hardcoded_parameters['magnitude_bin'] cprob = numpy.ones_like(magnitude_bin, dtype=float) if total_fatalities > 1: cprob = log_normal_cdf( magnitude_bin, median=total_fatalities, sigma=zeta) cprob = numpy.append(cprob, 1.0) prob = numpy.hstack((cprob[0], numpy.diff(cprob))) * 100.0 return self.round_to_sum(prob)