def setUp(self): self.density = gr.Density( marginals=dict( x=gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }), y=gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }), ), copula=gr.CopulaGaussian(["x", "y"], pd.DataFrame( dict(var1=["x"], var2=["y"], corr=[0.5]))), ) self.density_ind = gr.Density( marginals=dict( x=gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }), y=gr.MarginalNamed(d_name="norm", d_param={ "loc": 0, "scale": 1 }), ), copula=gr.CopulaIndependence(["x", "y"]), ) self.density_gauss = gr.Density( marginals=dict( x=gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }), y=gr.MarginalNamed(d_name="norm", d_param={ "loc": 0, "scale": 1 }), ), copula=gr.CopulaGaussian(["x", "y"], pd.DataFrame( dict(var1=["x"], var2=["y"], corr=[0.5]))), )
def setUp(self): # Default model self.df_wrong = pd.DataFrame(data={"z": [0.0, 1.0]}) # 2D identity model with permuted df inputs domain_2d = gr.Domain(bounds={"x0": [-1.0, +1.0], "x1": [0.0, 1.0]}) marginals = {} marginals["x0"] = gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }) marginals["x1"] = gr.MarginalNamed( sign=-1, d_name="uniform", d_param={ "loc": 0, "scale": 1 }, ) self.model_2d = gr.Model( functions=[ gr.Function(lambda x: [x[0], x[1]], ["x0", "x1"], ["y0", "y1"], "test", 0), ], domain=domain_2d, density=gr.Density(marginals=marginals), ) self.df_2d = pd.DataFrame(data={"x1": [0.0], "x0": [+1.0]}) self.res_2d = self.model_2d.evaluate_df(self.df_2d) self.df_median_in = pd.DataFrame({"x0": [0.5], "x1": [0.5]}) self.df_median_out = pd.DataFrame({"x0": [0.0], "x1": [0.5]}) self.model_3d = gr.Model( functions=[ gr.Function(lambda x: x[0] + x[1] + x[2], ["x", "y", "z"], ["f"], "test", 0) ], density=gr.Density(marginals=marginals), ) ## Timing check self.model_slow = gr.Model(functions=[ gr.Function(lambda x: x, ["x0"], ["y0"], "f0", 1), gr.Function(lambda x: x, ["x0"], ["y1"], "f1", 1), ])
def setUp(self): # 2D identity model with permuted df inputs domain_2d = gr.Domain(bounds={"x": [-1.0, +1], "y": [0.0, 1.0]}) marginals = {} marginals["x"] = gr.MarginalNamed( d_name="uniform", d_param={"loc": -1, "scale": 2} ) marginals["y"] = gr.MarginalNamed( sign=-1, d_name="uniform", d_param={"loc": 0, "scale": 1} ) self.model_2d = gr.Model( functions=[ gr.Function(lambda x: [x[0], x[1]], ["x", "y"], ["f", "g"], "test", 0) ], domain=domain_2d, density=gr.Density( marginals=marginals, copula=gr.CopulaIndependence(var_rand=["x"]) ), ) ## Correct results self.df_2d_nominal = pd.DataFrame( data={"x": [0.0], "y": [0.5], "f": [0.0], "g": [0.5]} ) self.df_2d_grad = pd.DataFrame( data={"Df_Dx": [1.0], "Dg_Dx": [0.0], "Df_Dy": [0.0], "Dg_Dy": [1.0]} ) self.df_2d_qe = pd.DataFrame( data={"x": [0.0], "y": [0.1], "f": [0.0], "g": [0.1]} )
def setUp(self): self.density = gr.Density( marginals=dict( x=gr.MarginalNamed(d_name="uniform", d_param={"loc": -1, "scale": 2}), y=gr.MarginalNamed(d_name="uniform", d_param={"loc": -1, "scale": 2}), ), copula=gr.CopulaGaussian( pd.DataFrame(dict(var1=["x"], var2=["y"], corr=[0.5])) ), )