Ejemplo n.º 1
0
 def test_2D_smoothing(self):
     """
     Test :meth:`bet.postProcess.plotP.smooth_marginals_2D`.
     """
     (bins, marginals) = plotP.calculate_2D_marginal_probs(self.P_samples, self.samples, self.lam_domain, nbins=10)
     marginals_smooth = plotP.smooth_marginals_2D(marginals, bins, sigma=10.0)
     nptest.assert_equal(marginals_smooth[(0, 1)].shape, marginals[(0, 1)].shape)
     nptest.assert_almost_equal(np.sum(marginals_smooth[(0, 1)]), 1.0)
Ejemplo n.º 2
0
There are ways to determine "optimal" smoothing parameters (e.g., see CV, GCV,
and other similar methods), but we have not incorporated these into the code
as lower-dimensional marginal plots generally have limited value in understanding
the structure of a high dimensional non-parametric probability measure.
'''
# calculate 2d marginal probs
(bins, marginals2D) = plotP.calculate_2D_marginal_probs(input_samples,
                                                        nbins = [30, 30])

# plot 2d marginals probs
plotP.plot_2D_marginal_probs(marginals2D, bins, input_samples,
                             filename = "validation_raw",
                             file_extension = ".eps", plot_surface=False)

# smooth 2d marginals probs (optional)
marginals2D = plotP.smooth_marginals_2D(marginals2D, bins, sigma=0.1)

# plot 2d marginals probs
plotP.plot_2D_marginal_probs(marginals2D, bins, input_samples,
                             filename = "validation_smooth",
                             file_extension = ".eps", plot_surface=False)

# calculate 1d marginal probs
(bins, marginals1D) = plotP.calculate_1D_marginal_probs(input_samples,
                                                        nbins = [30, 30])

# plot 2d marginal probs
plotP.plot_1D_marginal_probs(marginals1D, bins, input_samples,
                             filename = "validation_raw",
                             file_extension = ".eps")
Ejemplo n.º 3
0
should be either the nbins values or sigma (which influences the kernel
density estimation with smaller values implying a density estimate that
looks more like a histogram and larger values smoothing out the values
more).

There are ways to determine "optimal" smoothing parameters (e.g., see CV, GCV,
and other similar methods), but we have not incorporated these into the code
as lower-dimensional marginal plots generally have limited value in understanding
the structure of a high dimensional non-parametric probability measure.
'''
# calculate 2d marginal probs
(bins, marginals2D) = plotP.calculate_2D_marginal_probs(input_samples,
                                                        nbins=[10, 10, 10])

# smooth 2d marginals probs (optional)
marginals2D = plotP.smooth_marginals_2D(marginals2D, bins, sigma=0.2)

# plot 2d marginals probs
plotP.plot_2D_marginal_probs(marginals2D,
                             bins,
                             input_samples,
                             filename="linearMap",
                             lam_ref=param_ref,
                             file_extension=".eps",
                             plot_surface=False)

# calculate 1d marginal probs
(bins, marginals1D) = plotP.calculate_1D_marginal_probs(input_samples,
                                                        nbins=[10, 10, 10])
# smooth 1d marginal probs (optional)
marginals1D = plotP.smooth_marginals_1D(marginals1D, bins, sigma=0.2)