Exemplo n.º 1
0
    def test_generate_gamma(self):
        process = RenewalProcess(GammaDensity(init=1.5),
                                 ConstantIntensity(init=10))
        process.set_params([1.5], [10])
        events = process.generate_events(10)
        process.fit(events, 10)

        true_params = [1.5, 10]
        fitted_params = [
            process._density_params[0], process._intensity_params[0]
        ]

        self.assertIterablesEqualWithTolerance(fitted_params, true_params)
Exemplo n.º 2
0
    def test_generate_invgauss(self):
        process = RenewalProcess(InvGaussDensity(init=0.3),
                                 ConstantIntensity(init=10))
        process.set_params([0.3], [10])
        events = process.generate_events(10)
        process.fit(events, 10)

        true_params = [0.3, 10]
        fitted_params = [
            process._density_params[0], process._intensity_params[0]
        ]

        self.assertIterablesEqualWithTolerance(fitted_params, true_params)
Exemplo n.º 3
0
    def test_generate_inhomog_gamma(self):
        process = RenewalProcess(
            GammaDensity(init=1.5),
            ConstantIntensity(init=1) + ExponentialDecay(init=[5, 200]))
        process.set_params([1.5], [1, 5, 200])
        events = process.generate_events(500)
        process.fit(events, 500)

        fitted_params = np.array(
            [*process.density_params_, *process.intensity_params_])
        true_params = [1.5, 1, 5, 200]

        self.assertIterablesEqualWithTolerance(fitted_params,
                                               true_params,
                                               min_factor=0.7,
                                               max_factor=1.3)