How to use the abcpy.continuousmodels.Normal function in abcpy

To help you get started, we’ve selected a few abcpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eth-cscs / abcpy / tests / perturbationkernel_tests.py View on Github external
def test_Raises(self):
        N1 = Normal([0.1, 0.01])
        N2 = Normal([0.3, N1])
        kernel = MultivariateNormalKernel([N1,N2,N1])
        with self.assertRaises(ValueError):
            JointPerturbationKernel([kernel])
github eth-cscs / abcpy / tests / jointapprox_lhd_tests.py View on Github external
def setUp(self):
        self.stat_calc1 = Identity(degree = 1, cross = 0)
        self.stat_calc2 = Identity(degree= 1, cross = 0)
        self.likfun1 = SynLikelihood(self.stat_calc1)
        self.likfun2 = SynLikelihood(self.stat_calc2)
        ## Define Models
        # define a uniform prior distribution
        self.mu = Uniform([[-5.0], [5.0]], name='mu')
        self.sigma = Uniform([[0.0], [10.0]], name='sigma')
        # define a Gaussian model
        self.model1 = Normal([self.mu,self.sigma])
        self.model2 = Normal([self.mu,self.sigma])

        #Check whether wrong sized distnacefuncs gives an error
        self.assertRaises(ValueError, ProductCombination, [self.model1,self.model2], [self.likfun1])

        self.jointapprox_lhd = ProductCombination([self.model1, self.model2], [self.likfun1, self.likfun2])
github eth-cscs / abcpy / examples / approx_lhd / pmc_hierarchical_models.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    grades_obs = [3.872486707973337, 4.6735380808674405, 3.9703538990858376, 4.11021272048805, 4.211048655421368, 4.154817956586653, 4.0046893064392695, 4.01891381384729, 4.123804757702919, 4.014941267301294, 3.888174595940634, 4.185275142948246, 4.55148774469135, 3.8954427675259016, 4.229264035335705, 3.839949451328312, 4.039402553532825, 4.128077814241238, 4.361488645531874, 4.086279074446419, 4.370801602256129, 3.7431697332475466, 4.459454162392378, 3.8873973643008255, 4.302566721487124, 4.05556051626865, 4.128817316703757, 3.8673704442215984, 4.2174459453805015, 4.202280254493361, 4.072851400451234, 3.795173229398952, 4.310702877332585, 4.376886328810306, 4.183704734748868, 4.332192463368128, 3.9071312388426587, 4.311681374107893, 3.55187913252144, 3.318878360783221, 4.187850500877817, 4.207923106081567, 4.190462065625179, 4.2341474252986036, 4.110228694304768, 4.1589891480847765, 4.0345604687633045, 4.090635481715123, 3.1384654393449294, 4.20375641386518, 4.150452690356067, 4.015304457401275, 3.9635442007388195, 4.075915739179875, 3.5702080541929284, 4.722333310410388, 3.9087618197155227, 4.3990088006390735, 3.968501165774181, 4.047603645360087, 4.109184340976979, 4.132424805281853, 4.444358334346812, 4.097211737683927, 4.288553086265748, 3.8668863066511303, 3.8837108501541007]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2], [0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location], [0.1]], )

    # The social background of a student
    background = Normal([[school_location], [0.1]], )

    # The grade a student would receive without any bias
    grade_without_additional_effects = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade_without_additional_effects-class_size-background

    # The data corresponding to model_2 defined below
    scholarship_obs = [2.7179657436207805, 2.124647285937229, 3.07193407853297, 2.335024761813643, 2.871893855192, 3.4332002458233837, 3.649996835818173, 3.50292335102711, 2.815638168018455, 2.3581613289315992, 2.2794821846395568, 2.8725835459926503, 3.5588573782815685, 2.26053126526137, 1.8998143530749971, 2.101110815311782, 2.3482974964831573, 2.2707679029919206, 2.4624550491079225, 2.867017757972507, 3.204249152084959, 2.4489542437714213, 1.875415915801106, 2.5604889644872433, 3.891985093269989, 2.7233633223405205, 2.2861070389383533, 2.9758813233490082, 3.1183403287267755, 2.911814060853062, 2.60896794303205, 3.5717098647480316, 3.3355752461779824, 1.99172284546858, 2.339937680892163, 2.9835630207301636, 2.1684912355975774, 3.014847335983034, 2.7844122961916202, 2.752119871525148, 2.1567428931391635, 2.5803629307680644, 2.7326646074552103, 2.559237193255186, 3.13478196958166, 2.388760269933492, 3.2822443541491815, 2.0114405441787437, 3.0380056368041073, 2.4889680313769724, 2.821660164621084, 3.343985964873723, 3.1866861970287808, 4.4535037154856045, 3.0026333138006027, 2.0675706089352612, 2.3835301730913185, 2.584208398359566, 3.288077633446465, 2.6955853384148183, 2.918315169739928, 3.2464814419322985, 2.1601516779909433, 3.231003347780546, 1.0893224045062178, 0.8032302688764734, 2.868438615047827]

    # A quantity that determines whether a student will receive a scholarship
    scholarship_without_additional_effects = Normal([[2], [0.5]], )

    # A quantity determining whether a student receives a scholarship, including his social background
    final_scholarship = scholarship_without_additional_effects + 3*background
github eth-cscs / abcpy / examples / extensions / graphicalmodels / pmcabc_graphical_model.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    grades_obs = [3.396010144702873, 4.028241323112599, 3.62536728374886, 4.480429613325388, 3.787787804731597, 3.5899690679086107, 4.1736660809715405, 4.1593985002639275, 4.311185599797756, 4.049607307458736, 4.154878620607175, 4.429684988710977, 3.7533184335061813, 4.127065260139277, 4.521082883155887, 4.294274689695604, 3.94464672887112, 4.157832218067926, 4.2411935748991, 4.178945229216105, 3.785717756612455, 4.900210170980145, 3.8400182404620633, 4.38150456491072, 4.177538374339252, 4.015592937396663, 4.140537380463723, 3.852151227951589, 4.213718852494517, 3.9974576730715636, 4.119116004215904, 3.889664747339427, 4.27617521495367, 3.705033455404327, 3.8546905507341243, 3.61034397123066, 3.951050063304417, 4.109516892585332, 4.251958297243783, 4.377282299313978, 4.182230067895948, 3.7016957956246976, 3.9867272122758415, 4.278252460995561, 3.6988271248197466, 3.946398833830572, 4.1906415617863235, 4.004123105115532, 4.514888610733722, 4.066627046665651, 4.070266390101292, 4.238018975996794, 3.8252827974408246, 4.112394933441697, 4.093704899981078, 3.565044873345844, 4.0258611357597385, 4.363343385761771, 4.08570600900867, 4.077273623002418, 3.8350649704413153, 4.031198987911091, 3.8605569436588647, 4.337029660312197, 3.9892864794157643, 3.943365738564718, 4.867738846698944]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2], [0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location], [0.1]], )

    # The social background from which a student originates
    background = Normal([[school_location], [0.1]], )

    # The grade a student would receive without any bias
    grade_without_additional_effects = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade_without_additional_effects-class_size-background

    # Define a summary statistics
    from abcpy.statistics import Identity
    statistics_calculator = Identity(degree = 2, cross = False)

    # Define a distance measure
    from abcpy.distances import LogReg
github eth-cscs / abcpy / examples / backends / mpi / mpi_pmc_hierarchical_models.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    grades_obs = [3.872486707973337, 4.6735380808674405, 3.9703538990858376, 4.11021272048805, 4.211048655421368, 4.154817956586653, 4.0046893064392695, 4.01891381384729, 4.123804757702919, 4.014941267301294, 3.888174595940634, 4.185275142948246, 4.55148774469135, 3.8954427675259016, 4.229264035335705, 3.839949451328312, 4.039402553532825, 4.128077814241238, 4.361488645531874, 4.086279074446419, 4.370801602256129, 3.7431697332475466, 4.459454162392378, 3.8873973643008255, 4.302566721487124, 4.05556051626865, 4.128817316703757, 3.8673704442215984, 4.2174459453805015, 4.202280254493361, 4.072851400451234, 3.795173229398952, 4.310702877332585, 4.376886328810306, 4.183704734748868, 4.332192463368128, 3.9071312388426587, 4.311681374107893, 3.55187913252144, 3.318878360783221, 4.187850500877817, 4.207923106081567, 4.190462065625179, 4.2341474252986036, 4.110228694304768, 4.1589891480847765, 4.0345604687633045, 4.090635481715123, 3.1384654393449294, 4.20375641386518, 4.150452690356067, 4.015304457401275, 3.9635442007388195, 4.075915739179875, 3.5702080541929284, 4.722333310410388, 3.9087618197155227, 4.3990088006390735, 3.968501165774181, 4.047603645360087, 4.109184340976979, 4.132424805281853, 4.444358334346812, 4.097211737683927, 4.288553086265748, 3.8668863066511303, 3.8837108501541007]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2], [0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location], [0.1]], )

    # The social background of a student
    background = Normal([[school_location], [0.1]], )

    # The grade a student would receive without any bias
    grade_without_additional_effects = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade_without_additional_effects-class_size-background

    # The data corresponding to model_2 defined below
    scholarship_obs = [2.7179657436207805, 2.124647285937229, 3.07193407853297, 2.335024761813643, 2.871893855192, 3.4332002458233837, 3.649996835818173, 3.50292335102711, 2.815638168018455, 2.3581613289315992, 2.2794821846395568, 2.8725835459926503, 3.5588573782815685, 2.26053126526137, 1.8998143530749971, 2.101110815311782, 2.3482974964831573, 2.2707679029919206, 2.4624550491079225, 2.867017757972507, 3.204249152084959, 2.4489542437714213, 1.875415915801106, 2.5604889644872433, 3.891985093269989, 2.7233633223405205, 2.2861070389383533, 2.9758813233490082, 3.1183403287267755, 2.911814060853062, 2.60896794303205, 3.5717098647480316, 3.3355752461779824, 1.99172284546858, 2.339937680892163, 2.9835630207301636, 2.1684912355975774, 3.014847335983034, 2.7844122961916202, 2.752119871525148, 2.1567428931391635, 2.5803629307680644, 2.7326646074552103, 2.559237193255186, 3.13478196958166, 2.388760269933492, 3.2822443541491815, 2.0114405441787437, 3.0380056368041073, 2.4889680313769724, 2.821660164621084, 3.343985964873723, 3.1866861970287808, 4.4535037154856045, 3.0026333138006027, 2.0675706089352612, 2.3835301730913185, 2.584208398359566, 3.288077633446465, 2.6955853384148183, 2.918315169739928, 3.2464814419322985, 2.1601516779909433, 3.231003347780546, 1.0893224045062178, 0.8032302688764734, 2.868438615047827]

    # A quantity that determines whether a student will receive a scholarship
    scholarship_without_additional_effects = Normal([[2], [0.5]], )

    # A quantity determining whether a student receives a scholarship, including his social background
    final_scholarship = scholarship_without_additional_effects + 3*background
github eth-cscs / abcpy / examples / hierarchicalmodels / pmcabc_inference_on_multiple_sets_of_obs.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    grades_obs = [3.872486707973337, 4.6735380808674405, 3.9703538990858376, 4.11021272048805, 4.211048655421368, 4.154817956586653, 4.0046893064392695, 4.01891381384729, 4.123804757702919, 4.014941267301294, 3.888174595940634, 4.185275142948246, 4.55148774469135, 3.8954427675259016, 4.229264035335705, 3.839949451328312, 4.039402553532825, 4.128077814241238, 4.361488645531874, 4.086279074446419, 4.370801602256129, 3.7431697332475466, 4.459454162392378, 3.8873973643008255, 4.302566721487124, 4.05556051626865, 4.128817316703757, 3.8673704442215984, 4.2174459453805015, 4.202280254493361, 4.072851400451234, 3.795173229398952, 4.310702877332585, 4.376886328810306, 4.183704734748868, 4.332192463368128, 3.9071312388426587, 4.311681374107893, 3.55187913252144, 3.318878360783221, 4.187850500877817, 4.207923106081567, 4.190462065625179, 4.2341474252986036, 4.110228694304768, 4.1589891480847765, 4.0345604687633045, 4.090635481715123, 3.1384654393449294, 4.20375641386518, 4.150452690356067, 4.015304457401275, 3.9635442007388195, 4.075915739179875, 3.5702080541929284, 4.722333310410388, 3.9087618197155227, 4.3990088006390735, 3.968501165774181, 4.047603645360087, 4.109184340976979, 4.132424805281853, 4.444358334346812, 4.097211737683927, 4.288553086265748, 3.8668863066511303, 3.8837108501541007]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2], [0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location], [0.1]], )

    # The social background of a student
    background = Normal([[school_location], [0.1]], )

    # The grade a student would receive without any bias
    grade_without_additional_effects = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade_without_additional_effects-class_size-background

    # The data corresponding to model_2 defined below
    scholarship_obs = [2.7179657436207805, 2.124647285937229, 3.07193407853297, 2.335024761813643, 2.871893855192, 3.4332002458233837, 3.649996835818173, 3.50292335102711, 2.815638168018455, 2.3581613289315992, 2.2794821846395568, 2.8725835459926503, 3.5588573782815685, 2.26053126526137, 1.8998143530749971, 2.101110815311782, 2.3482974964831573, 2.2707679029919206, 2.4624550491079225, 2.867017757972507, 3.204249152084959, 2.4489542437714213, 1.875415915801106, 2.5604889644872433, 3.891985093269989, 2.7233633223405205, 2.2861070389383533, 2.9758813233490082, 3.1183403287267755, 2.911814060853062, 2.60896794303205, 3.5717098647480316, 3.3355752461779824, 1.99172284546858, 2.339937680892163, 2.9835630207301636, 2.1684912355975774, 3.014847335983034, 2.7844122961916202, 2.752119871525148, 2.1567428931391635, 2.5803629307680644, 2.7326646074552103, 2.559237193255186, 3.13478196958166, 2.388760269933492, 3.2822443541491815, 2.0114405441787437, 3.0380056368041073, 2.4889680313769724, 2.821660164621084, 3.343985964873723, 3.1866861970287808, 4.4535037154856045, 3.0026333138006027, 2.0675706089352612, 2.3835301730913185, 2.584208398359566, 3.288077633446465, 2.6955853384148183, 2.918315169739928, 3.2464814419322985, 2.1601516779909433, 3.231003347780546, 1.0893224045062178, 0.8032302688764734, 2.868438615047827]

    # A quantity that determines whether a student will receive a scholarship
    scholarship_without_additional_effects = Normal([[2], [0.5]], )

    # A quantity determining whether a student receives a scholarship, including his social background
    final_scholarship = scholarship_without_additional_effects + 3*background

    # Define a summary statistics for final grade and final scholarship
    from abcpy.statistics import Identity
    statistics_calculator_final_grade = Identity(degree = 2, cross = False)
github eth-cscs / abcpy / examples / extensions / perturbationkernels / pmcabc_perturbation_kernels.py View on Github external
class_size = Normal([[school_location[0]], [0.1]], )

    # The social background of a student
    background = Normal([[school_location[1]], [0.1]], )

    # The grade a student would receive without any bias
    grade = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade-class_size-background

    # The data corresponding to model_2 defined below
    y_obs_scholarship = [2.7179657436207805, 2.124647285937229, 3.07193407853297, 2.335024761813643, 2.871893855192, 3.4332002458233837, 3.649996835818173, 3.50292335102711, 2.815638168018455, 2.3581613289315992, 2.2794821846395568, 2.8725835459926503, 3.5588573782815685, 2.26053126526137, 1.8998143530749971, 2.101110815311782, 2.3482974964831573, 2.2707679029919206, 2.4624550491079225, 2.867017757972507, 3.204249152084959, 2.4489542437714213, 1.875415915801106, 2.5604889644872433, 3.891985093269989, 2.7233633223405205, 2.2861070389383533, 2.9758813233490082, 3.1183403287267755, 2.911814060853062, 2.60896794303205, 3.5717098647480316, 3.3355752461779824, 1.99172284546858, 2.339937680892163, 2.9835630207301636, 2.1684912355975774, 3.014847335983034, 2.7844122961916202, 2.752119871525148, 2.1567428931391635, 2.5803629307680644, 2.7326646074552103, 2.559237193255186, 3.13478196958166, 2.388760269933492, 3.2822443541491815, 2.0114405441787437, 3.0380056368041073, 2.4889680313769724, 2.821660164621084, 3.343985964873723, 3.1866861970287808, 4.4535037154856045, 3.0026333138006027, 2.0675706089352612, 2.3835301730913185, 2.584208398359566, 3.288077633446465, 2.6955853384148183, 2.918315169739928, 3.2464814419322985, 2.1601516779909433, 3.231003347780546, 1.0893224045062178, 0.8032302688764734, 2.868438615047827]

    # A quantity that determines whether a student will receive a scholarship
    scholarship = Normal([[2], [0.5]], )

    # A quantity determining whether a student receives a scholarship, including his social background
    final_scholarship = scholarship + 3*background

    # Define a summary statistics
    from abcpy.statistics import Identity
    statistics_calculator = Identity(degree = 2, cross = False)

    # Define a distance measure
    from abcpy.distances import Euclidean
    distance_calculator = Euclidean(statistics_calculator)

    # Define a backend
    from abcpy.backends import BackendDummy as Backend
    backend = Backend()
github eth-cscs / abcpy / examples / extensions / graphicalmodels / pmcabc_graphical_model.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    grades_obs = [3.396010144702873, 4.028241323112599, 3.62536728374886, 4.480429613325388, 3.787787804731597, 3.5899690679086107, 4.1736660809715405, 4.1593985002639275, 4.311185599797756, 4.049607307458736, 4.154878620607175, 4.429684988710977, 3.7533184335061813, 4.127065260139277, 4.521082883155887, 4.294274689695604, 3.94464672887112, 4.157832218067926, 4.2411935748991, 4.178945229216105, 3.785717756612455, 4.900210170980145, 3.8400182404620633, 4.38150456491072, 4.177538374339252, 4.015592937396663, 4.140537380463723, 3.852151227951589, 4.213718852494517, 3.9974576730715636, 4.119116004215904, 3.889664747339427, 4.27617521495367, 3.705033455404327, 3.8546905507341243, 3.61034397123066, 3.951050063304417, 4.109516892585332, 4.251958297243783, 4.377282299313978, 4.182230067895948, 3.7016957956246976, 3.9867272122758415, 4.278252460995561, 3.6988271248197466, 3.946398833830572, 4.1906415617863235, 4.004123105115532, 4.514888610733722, 4.066627046665651, 4.070266390101292, 4.238018975996794, 3.8252827974408246, 4.112394933441697, 4.093704899981078, 3.565044873345844, 4.0258611357597385, 4.363343385761771, 4.08570600900867, 4.077273623002418, 3.8350649704413153, 4.031198987911091, 3.8605569436588647, 4.337029660312197, 3.9892864794157643, 3.943365738564718, 4.867738846698944]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2], [0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location], [0.1]], )

    # The social background from which a student originates
    background = Normal([[school_location], [0.1]], )

    # The grade a student would receive without any bias
    grade_without_additional_effects = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade_without_additional_effects-class_size-background

    # Define a summary statistics
    from abcpy.statistics import Identity
    statistics_calculator = Identity(degree = 2, cross = False)

    # Define a distance measure
    from abcpy.distances import LogReg
    distance_calculator = LogReg(statistics_calculator)

    # Define a backend
    from abcpy.backends import BackendDummy as Backend
    backend = Backend()
github eth-cscs / abcpy / examples / extensions / perturbationkernels / pmcabc_perturbation_kernels.py View on Github external
def infer_parameters():
    # The data corresponding to model_1 defined below
    y_obs_grades = [3.872486707973337, 4.6735380808674405, 3.9703538990858376, 4.11021272048805, 4.211048655421368, 4.154817956586653, 4.0046893064392695, 4.01891381384729, 4.123804757702919, 4.014941267301294, 3.888174595940634, 4.185275142948246, 4.55148774469135, 3.8954427675259016, 4.229264035335705, 3.839949451328312, 4.039402553532825, 4.128077814241238, 4.361488645531874, 4.086279074446419, 4.370801602256129, 3.7431697332475466, 4.459454162392378, 3.8873973643008255, 4.302566721487124, 4.05556051626865, 4.128817316703757, 3.8673704442215984, 4.2174459453805015, 4.202280254493361, 4.072851400451234, 3.795173229398952, 4.310702877332585, 4.376886328810306, 4.183704734748868, 4.332192463368128, 3.9071312388426587, 4.311681374107893, 3.55187913252144, 3.318878360783221, 4.187850500877817, 4.207923106081567, 4.190462065625179, 4.2341474252986036, 4.110228694304768, 4.1589891480847765, 4.0345604687633045, 4.090635481715123, 3.1384654393449294, 4.20375641386518, 4.150452690356067, 4.015304457401275, 3.9635442007388195, 4.075915739179875, 3.5702080541929284, 4.722333310410388, 3.9087618197155227, 4.3990088006390735, 3.968501165774181, 4.047603645360087, 4.109184340976979, 4.132424805281853, 4.444358334346812, 4.097211737683927, 4.288553086265748, 3.8668863066511303, 3.8837108501541007]

    # The prior information changing the class size and social background, depending on school location
    from abcpy.continuousmodels import Uniform, Normal
    school_location = Uniform([[0.2, 0.2], [0.3, 0.3]], )

    # The average class size of a certain school
    class_size = Normal([[school_location[0]], [0.1]], )

    # The social background of a student
    background = Normal([[school_location[1]], [0.1]], )

    # The grade a student would receive without any bias
    grade = Normal([[4.5], [0.25]], )

    # The grade a student of a certain school receives
    final_grade = grade-class_size-background

    # The data corresponding to model_2 defined below
    y_obs_scholarship = [2.7179657436207805, 2.124647285937229, 3.07193407853297, 2.335024761813643, 2.871893855192, 3.4332002458233837, 3.649996835818173, 3.50292335102711, 2.815638168018455, 2.3581613289315992, 2.2794821846395568, 2.8725835459926503, 3.5588573782815685, 2.26053126526137, 1.8998143530749971, 2.101110815311782, 2.3482974964831573, 2.2707679029919206, 2.4624550491079225, 2.867017757972507, 3.204249152084959, 2.4489542437714213, 1.875415915801106, 2.5604889644872433, 3.891985093269989, 2.7233633223405205, 2.2861070389383533, 2.9758813233490082, 3.1183403287267755, 2.911814060853062, 2.60896794303205, 3.5717098647480316, 3.3355752461779824, 1.99172284546858, 2.339937680892163, 2.9835630207301636, 2.1684912355975774, 3.014847335983034, 2.7844122961916202, 2.752119871525148, 2.1567428931391635, 2.5803629307680644, 2.7326646074552103, 2.559237193255186, 3.13478196958166, 2.388760269933492, 3.2822443541491815, 2.0114405441787437, 3.0380056368041073, 2.4889680313769724, 2.821660164621084, 3.343985964873723, 3.1866861970287808, 4.4535037154856045, 3.0026333138006027, 2.0675706089352612, 2.3835301730913185, 2.584208398359566, 3.288077633446465, 2.6955853384148183, 2.918315169739928, 3.2464814419322985, 2.1601516779909433, 3.231003347780546, 1.0893224045062178, 0.8032302688764734, 2.868438615047827]

    # A quantity that determines whether a student will receive a scholarship
    scholarship = Normal([[2], [0.5]], )

    # A quantity determining whether a student receives a scholarship, including his social background
    final_scholarship = scholarship + 3*background
github eth-cscs / abcpy / examples / modelselection / randomforest_modelselections.py View on Github external
def infer_model():
    # define observation for true parameters mean=170, std=15
    y_obs = [160.82499176]

    ## Create a array of models
    from abcpy.continuousmodels import Uniform, Normal, StudentT
    model_array = [None]*2

    #Model 1: Gaussian
    mu1 = Uniform([[150], [200]], name='mu1')
    sigma1 = Uniform([[5.0], [25.0]], name='sigma1')
    model_array[0] = Normal([mu1, sigma1])
    
    #Model 2: Student t
    mu2 = Uniform([[150], [200]], name='mu2')
    sigma2 = Uniform([[1], [30.0]], name='sigma2')
    model_array[1] = StudentT([mu2, sigma2])

    # define statistics
    from abcpy.statistics import Identity
    statistics_calculator = Identity(degree = 2, cross = False)

    # define backend
    from abcpy.backends import BackendDummy as Backend
    backend = Backend()

    # Initiate the Model selection scheme
    modelselection = RandomForest(model_array, statistics_calculator, backend, seed = 1)