Beispiel #1
0
    def setUp(self):
        """
        Set up problem.
        """
        self.rho_D_M, self.d_distr_samples, self.d_Tree = sFun.unif_unif(self.data, 
                self.Q_ref, M=67, bin_ratio=0.1, num_d_emulate=1E3)

        if type(self.Q_ref) != np.array:
            self.Q_ref = np.array([self.Q_ref])
        if len(self.data_domain.shape) == 1:
            self.data_domain = np.expand_dims(self.data_domain, axis=0)

        self.rect_domain = np.zeros((self.data_domain.shape[0], 2))
        r_width = 0.1*self.data_domain[:, 1]

        self.rect_domain[:, 0] = self.Q_ref - .5*r_width
        self.rect_domain[:, 1] = self.Q_ref + .5*r_width
Beispiel #2
0
# Plot the data domain
plotD.show_data(data, Q_ref = Q_ref, rho_D=rho_D, showdim=2)

# Whether or not to use deterministic description of simple function approximation of
# ouput probability
deterministic_discretize_D = True
if deterministic_discretize_D == True:
  (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.uniform_hyperrectangle(data=data,
                                                                              Q_ref=Q_ref, 
                                                                              bin_ratio=bin_ratio, 
                                                                              center_pts_per_edge = 1)
else:
  (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.unif_unif(data=data,
                                                                 Q_ref=Q_ref, 
                                                                 M=50, 
                                                                 bin_ratio=bin_ratio, 
                                                                 num_d_emulate=1E5)
  
# calculate probablities making Monte Carlo assumption
(P,  lam_vol, io_ptr) = calculateP.prob(samples=samples,
                                        data=data,
                                        rho_D_M=d_distr_prob,
                                        d_distr_samples=d_distr_samples)

# calculate 2D marginal probabilities
(bins, marginals2D) = plotP.calculate_2D_marginal_probs(P_samples = P, samples = samples, lam_domain = lam_domain, nbins = 10)

# smooth 2D marginal probabilites for plotting (optional)
marginals2D = plotP.smooth_marginals_2D(marginals2D,bins, sigma=1.0)
unif_unif, but the difference is in the discretization which is on a 
regular grid defined by center_pts_per_edge. If center_pts_per_edge = 1, 
then the contour event corresponding to the entire support of rho_D is
approximated as a single event. This is done by carefully placing a 
regular 3x3 grid (for the D=2 case) of points in D with the center
point of the grid in the center of the support of the measure and the 
other points placed outside of the rectangle defining the support to 
define a total of 9 contour events with 8 of them with zero probability.
'''
deterministic_discretize_D = True

if deterministic_discretize_D == True:
  (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.uniform_hyperrectangle(data=data,
                                              Q_ref=Q_ref, bin_ratio=0.2, center_pts_per_edge = 1)
else:
  (d_distr_prob, d_distr_samples, d_Tree) = simpleFunP.unif_unif(data=data,
                                              Q_ref=Q_ref, M=50, bin_ratio=0.2, num_d_emulate=1E5)


# create emulated points
'''
Suggested changes for user:
    
If using a regular grid of sampling (if random_sample = False), we set
    
  lambda_emulate = samples
  
Otherwise, play around with num_l_emulate. A value of 1E2 will probably
give poor results while results become fairly consistent with values 
that are approximately 10x the number of samples.
   
Note that you can always use
other points placed outside of the rectangle defining the support to 
define a total of 9 contour events with 8 of them with zero probability.
'''
deterministic_discretize_D = True

if deterministic_discretize_D == True:
    (d_distr_prob, d_distr_samples,
     d_Tree) = simpleFunP.uniform_hyperrectangle(data=data,
                                                 Q_ref=Q_ref,
                                                 bin_ratio=0.2,
                                                 center_pts_per_edge=1)
else:
    (d_distr_prob, d_distr_samples,
     d_Tree) = simpleFunP.unif_unif(data=data,
                                    Q_ref=Q_ref,
                                    M=50,
                                    bin_ratio=0.2,
                                    num_d_emulate=1E5)

# create emulated points
'''
Suggested changes for user:
    
If using a regular grid of sampling (if random_sample = False), we set
    
  lambda_emulate = samples
  
Otherwise, play around with num_l_emulate. A value of 1E2 will probably
give poor results while results become fairly consistent with values 
that are approximately 10x the number of samples.