xboa
|
VoronoiWeighting class enables the user to set statistical weights of Hits in a Bunch based on how close they are to neighbouring Hits. More...
Inherits object.
Public Member Functions | |
def | __init__ |
Initialise the VoronoiWeighting. More... | |
def | apply_weights |
Apply a weighting ![]() ![]() where ![]() ![]() ![]() | |
def | get_pdf |
Calculate a multivariate gaussian at point. More... | |
def | plot_two_d_projection |
Plot a 2D projection of the voronoi cells. More... | |
Public Attributes | |
dim | |
voronoi_bound | |
weight_variables | |
weight_ellipse_inv | |
weight_ellipse_det | |
weight_mean | |
weight_list | |
tesselation | |
tile_content_list | |
real_points | |
Private Member Functions | |
def | _get_fill_colors |
Get fill colors for plot_two_d_projection. More... | |
def | _get_cm_matrix |
def | _tile_content |
Calculate the tile for the index at point_index. More... | |
VoronoiWeighting class enables the user to set statistical weights of Hits in a Bunch based on how close they are to neighbouring Hits.
The basic principle is that if a Hit is in a sparsely populated region of phase space, but the desired probability distribution would have the Hit in a more densely populated region, we can apply a greater statistical weight to that Hit (i.e. we "count" the Hit more than once in e.g. moment calculations etc).
In order to calculate how sparsely populated a particular region is, xboa uses a "Voronoi" tesselation. xboa determines the nearest Hits surrounding a given Hit, draws lines to those neighbours and then bisects the lines. This generates a closed region around the Hit that is closer to that Hit than any other.
xboa calculates the "content" i.e. area/volume/hypervolume of the Voronoi tile for each Hit. Hits which sit in a tile with a larger content are assumed to be in a more sparsely populated region of phase space, while those that sit in a region with a smaller content are assumed to be in a less sparsely populated region of phase space.
xboa assigns weights to each Hit according to a multivariate gaussian. In order to prevent Hits on the edge of the distribution from acquiring a disproportionate weighting, it is possible to define a bound around the distribution. Hits outside the bound are disregarded. A few points are defined on the bound, which prevent large Voronoi cells from being generated.
Definition at line 70 of file _voronoi_weighting.py.
def __init__ | ( | self, | |
weight_variables, | |||
weight_ellipse, | |||
weight_mean = None , |
|||
voronoi_bound = None |
|||
) |
Initialise the VoronoiWeighting.
Requires numpy and scipy to be installed.
Returns a VoronoiWeighting object.
Definition at line 97 of file _voronoi_weighting.py.
def apply_weights | ( | self, | |
bunch, | |||
global_cut | |||
) |
Apply a weighting to each Hit in bunch corresponding to
where is the content of each Voronoi tile and
is the value of a multivariate gaussian evaluated at
.
Definition at line 141 of file _voronoi_weighting.py.
References VoronoiWeighting._tile_content(), VoronoiWeighting.get_pdf(), VoronoiWeighting.real_points, VoronoiWeighting.tesselation, VoronoiWeighting.tile_content_list, VoronoiWeighting.voronoi_bound, VoronoiWeighting.weight_list, and VoronoiWeighting.weight_variables.
def get_pdf | ( | self, | |
point | |||
) |
Calculate a multivariate gaussian at point.
Definition at line 184 of file _voronoi_weighting.py.
References VoronoiWeighting.plot_two_d_projection(), VoronoiWeighting.weight_ellipse_det, and VoronoiWeighting.weight_mean.
Referenced by VoronoiWeighting._get_fill_colors(), and VoronoiWeighting.apply_weights().
def plot_two_d_projection | ( | self, | |
projection_axes, | |||
fill_option = None , |
|||
lower = None , |
|||
upper = None |
|||
) |
Plot a 2D projection of the voronoi cells.
Requires ROOT to be installed.
Returns a tuple of (canvas, histogram, point_graph, tile_graph_list) where canvas is the ROOT TCanvas, histogram is the ROOT TH2D that makes the graph axes, point_graph is the graph with the points plotted, tile_graph_list is a list of graphs, one for each tile.
Definition at line 214 of file _voronoi_weighting.py.
References VoronoiWeighting._get_fill_colors(), VoronoiWeighting.real_points, VoronoiWeighting.tesselation, and VoronoiWeighting.weight_variables.
Referenced by VoronoiWeighting.get_pdf().
|
private |
Get fill colors for plot_two_d_projection.
Definition at line 272 of file _voronoi_weighting.py.
References VoronoiWeighting.get_pdf(), VoronoiWeighting.real_points, VoronoiWeighting.tile_content_list, and VoronoiWeighting.weight_list.
Referenced by VoronoiWeighting.plot_two_d_projection().
|
private |
Definition at line 292 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting._tile_content().
|
private |
Calculate the tile for the index at point_index.
Use Cayler-Menger determinant to calculate content of an arbitrary dimensional simplex.
Definition at line 316 of file _voronoi_weighting.py.
References VoronoiWeighting._get_cm_matrix().
Referenced by VoronoiWeighting.apply_weights().
dim |
Definition at line 100 of file _voronoi_weighting.py.
voronoi_bound |
Definition at line 113 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting.apply_weights().
weight_variables |
Definition at line 120 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting.apply_weights(), and VoronoiWeighting.plot_two_d_projection().
weight_ellipse_inv |
Definition at line 121 of file _voronoi_weighting.py.
weight_ellipse_det |
Definition at line 122 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting.get_pdf().
weight_mean |
Definition at line 123 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting.get_pdf().
weight_list |
Definition at line 124 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting._get_fill_colors(), and VoronoiWeighting.apply_weights().
tesselation |
Definition at line 125 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting.apply_weights(), and VoronoiWeighting.plot_two_d_projection().
tile_content_list |
Definition at line 126 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting._get_fill_colors(), and VoronoiWeighting.apply_weights().
real_points |
Definition at line 127 of file _voronoi_weighting.py.
Referenced by VoronoiWeighting._get_fill_colors(), VoronoiWeighting.apply_weights(), and VoronoiWeighting.plot_two_d_projection().