def logistic_mixture_norm_test(): xscale = Scale(-50, 50) return LogisticMixture( components=[Logistic(-40, 1, xscale), Logistic(50, 10, xscale)], probs=[0.5, 0.5], )
def normalized_logistic_mixture(): return LogisticMixture( components=[ Logistic(loc=0.15, s=0.037034005, scale=Scale(0, 1)), Logistic(loc=0.85, s=0.032395907, scale=Scale(0, 1)), ], probs=[0.6, 0.4], )
def logistic_mixture(): return LogisticMixture( components=[ Logistic(loc=10000, scale=1000), Logistic(loc=100000, scale=10000) ], probs=[0.8, 0.2], )
def logistic_mixture_p_overlapping(): xscale = three_sd_scale(4000000.035555004, 200000.02) return LogisticMixture( components=[ Logistic(4000000.035555004, 200000.02, xscale), Logistic(4000000.0329152746, 200000.0, xscale), ], probs=[0.5, 0.5], )
def logistic_mixture_p_uneven(): xscale = Scale(-10, 20) return LogisticMixture( components=[ Logistic(loc=10, s=3, scale=xscale), Logistic(loc=5, s=5, scale=xscale), ], probs=[1.8629593e-29, 1.0], )
def logistic_mixture10(): xscale = Scale(-20, 40) return LogisticMixture( components=[ Logistic(loc=15, s=2.3658268, scale=xscale), Logistic(loc=5, s=2.3658268, scale=xscale), ], probs=[0.5, 0.5], )
def logistic_mixture(): xscale = Scale(0, 150000) return LogisticMixture( components=[ Logistic(loc=10000, s=1000, scale=xscale), Logistic(loc=100000, s=10000, scale=xscale), ], probs=[0.8, 0.2], )
def logistic_mixture15(): xscale = Scale(-10, 40) return LogisticMixture( components=[ Logistic(loc=10, s=3.658268, scale=xscale), Logistic(loc=20, s=3.658268, scale=xscale), ], probs=[0.5, 0.5], )
def smooth_logistic_mixture(): xscale = Scale(1, 1000000.0) return LogisticMixture( components=[ Logistic(loc=400000, s=100000, scale=xscale), Logistic(loc=700000, s=50000, scale=xscale), ], probs=[0.8, 0.2], )
def truncated_logistic_mixture(): xscale = Scale(5000, 120000) return LogisticMixture( components=[ Truncate( Logistic(loc=10000, s=1000, scale=xscale), floor=5000, ceiling=500000 ), Truncate( Logistic(loc=100000, s=10000, scale=xscale), floor=5000, ceiling=500000 ), ], probs=[0.8, 0.2], )
def get_true_scale_mixture( self, normalized_dist: LogisticMixture) -> LogisticMixture: """ Convert a normalized logistic mixture distribution to a logistic on the true scale of the question. :param normalized_dist: normalized logistic mixture dist :return: same distribution rescaled to the true scale of the question """ true_scale_logistics = [ self.get_true_scale_logistic(c) for c in normalized_dist.components ] return LogisticMixture(true_scale_logistics, normalized_dist.probs)
def test_percentiles_from_mixture(): xscale = Scale(-1, 4) mixture = LogisticMixture( components=[ Logistic(loc=1, s=0.1, scale=xscale), Logistic(loc=2, s=0.1, scale=xscale), ], probs=[0.5, 0.5], ) conditions = mixture.percentiles(percentiles=[0.1, 0.5, 0.9]) for condition in conditions: if condition.max == 0.5: assert condition.p == pytest.approx(1.5, rel=0.01) return conditions