def setUp(self): """ Set up problem. """ super(Test_prob_on_emulated_samples_10to4, self).setUp() calcP.prob_on_emulated_samples(self.disc)
def setUp(self): """ Set up problem. """ super(Test_prob_on_emulated_samples_3to1, self).setUp() calcP.prob_on_emulated_samples(self.disc) self.P_emulate_ref = np.loadtxt(data_path+"/3to1_prob_emulated.txt.gz")
def postprocess(station_nums, ref_num): filename = 'P_q' + str(station_nums[0] + 1) + \ '_q' + str(station_nums[1] + 1) if len(station_nums) == 3: filename += '_q' + str(station_nums[2] + 1) filename += '_ref_' + str(ref_num + 1) data = Q[:, station_nums] output_sample_set = sample.sample_set(data.shape[1]) output_sample_set.set_values(data) q_ref = Q_ref[ref_num, station_nums] # Create Simple function approximation # Save points used to parition D for simple function approximation and the # approximation itself (this can be used to make close comparisions...) output_probability_set = sfun.regular_partition_uniform_distribution_rectangle_scaled( output_sample_set, q_ref, rect_scale=0.15, cells_per_dimension=np.ones((data.shape[1], ))) num_l_emulate = 1e4 set_emulated = bsam.random_sample_set('r', lam_domain, num_l_emulate) my_disc = sample.discretization(input_sample_set, output_sample_set, output_probability_set, emulated_input_sample_set=set_emulated) print("Finished emulating lambda samples") # Calculate P on lambda emulate print("Calculating prob_on_emulated_samples") calcP.prob_on_emulated_samples(my_disc) sample.save_discretization(my_disc, filename, "prob_on_emulated_samples_solution") # Calclate P on the actual samples with assumption that voronoi cells have # equal size input_sample_set.estimate_volume_mc() print("Calculating prob") calcP.prob(my_disc) sample.save_discretization(my_disc, filename, "prob_solution") # Calculate P on the actual samples estimating voronoi cell volume with MC # integration calcP.prob_with_emulated_volumes(my_disc) print("Calculating prob_with_emulated_volumes") sample.save_discretization(my_disc, filename, "prob_with_emulated_volumes_solution")
def postprocess(station_nums, ref_num): filename = 'P_q'+str(station_nums[0]+1)+'_q' if len(station_nums) == 3: filename += '_q'+str(station_nums[2]+1) filename += '_ref_'+str(ref_num+1) data = Q[:, station_nums] output_sample_set = sample.sample_set(data.shape[1]) output_sample_set.set_values(data) q_ref = Q_ref[ref_num, station_nums] # Create Simple function approximation # Save points used to parition D for simple function approximation and the # approximation itself (this can be used to make close comparisions...) output_probability_set = sfun.regular_partition_uniform_distribution_rectangle_scaled(\ output_sample_set, q_ref, rect_scale=0.15, cells_per_dimension=np.ones((data.shape[1],))) num_l_emulate = 1e4 set_emulated = bsam.random_sample_set('r', lam_domain, num_l_emulate) my_disc = sample.discretization(input_sample_set, output_sample_set, output_probability_set, emulated_input_sample_set=set_emulated) print "Finished emulating lambda samples" # Calculate P on lambda emulate print "Calculating prob_on_emulated_samples" calcP.prob_on_emulated_samples(my_disc) sample.save_discretization(my_disc, filename, "prob_on_emulated_samples_solution") # Calclate P on the actual samples with assumption that voronoi cells have # equal size input_sample_set.estimate_volume_mc() print "Calculating prob" calcP.prob(my_disc) sample.save_discretization(my_disc, filename, "prob_solution") # Calculate P on the actual samples estimating voronoi cell volume with MC # integration calcP.prob_with_emulated_volumes(my_disc) print "Calculating prob_with_emulated_volumes" sample.save_discretization(my_disc, filename, "prob_with_emulated_volumes_solution")