예제 #1
0
    def test(self):
        def prior(p):
            return 1.0

        bounds = [[-1, 1], [-1, 1], [-1, 1]]

        estimator = fitter.BayesianMCMCFitter(
            likelihood=loss.likelihood,
            prior=prior,
            bounds=bounds,
            model=physics_model.BeamSpinAsymmetryModel())

        x, y = estimator.samples.shape
        self.assertTrue(x == estimator.n_iterations)
        self.assertTrue(y == estimator.model.n_pars)
예제 #2
0
    def test(self):
        estimator = fitter.SingleFitter(
            loss_function=loss.chi2,
            model=physics_model.BeamSpinAsymmetryModel())

        # generate a test set
        phi = np.linspace(-175.0, 175.0, 17)
        value = estimator.model.evaluate(phi) + np.random.normal(
            0, 0.01, len(phi))
        error = np.repeat(0.05, len(phi))

        # do fitting
        true_pars = estimator.model.pars
        result = estimator.fit(phi, value, error)

        self.assertTrue(len(result.fit_parameters) is estimator.model.n_pars)
예제 #3
0
    def test(self):
        def prior(p):
            return 1.0

        bounds = [[-1, 1], [-1, 1], [-1, 1]]
        estimator = fitter.BayesianVegasFitter(
            likelihood=loss.likelihood,
            prior=prior,
            bounds=bounds,
            model=physics_model.BeamSpinAsymmetryModel(),
            n_iterations=10,
            n_evaluations=15000)

        # generate a test set
        phi = np.linspace(-175.0, 175.0, 17)
        value = estimator.model.evaluate(phi) + np.random.normal(
            0, 0.05, len(phi))
        error = np.repeat(0.05, len(phi))

        # do fitting
        true_pars = estimator.model.pars
        result = estimator.fit(phi, value, error)

        self.assertTrue(len(result.fit_parameters) is estimator.model.n_pars)
예제 #4
0
    def test(self):

        #        cores = multiprocessing.cpu_count()
        #        if not cores:

        # just test single core for now
        cores = 1
        estimator = fitter.ReplicaFitter(
            loss_function=loss.chi2,
            model=physics_model.BeamSpinAsymmetryModel(),
            n_cores=cores,
            n_replicas=20)

        # generate a test set
        phi = np.linspace(-175.0, 175.0, 17)
        value = estimator.model.evaluate(phi) + np.random.normal(
            0, 0.05, len(phi))
        error = np.repeat(0.05, len(phi))

        # do fitting
        true_pars = estimator.model.pars
        result = estimator.fit(phi, value, error)

        self.assertTrue(len(result.fit_parameters) is estimator.model.n_pars)