Effective Fisher API Reference
Module of routines to compute an effective Fisher matrix and related utilities, such as finding a region of interest and laying out a grid over it
- RIFT.physics.effectiveFisher.array_to_symmetric_matrix(gamma)
Given a flat array of length N*(N+1)/2 consisting of the upper right triangle of a symmetric matrix, return an NxN numpy array of the symmetric matrix
- Example:
gamma = [1, 2, 3, 4, 5, 6] array_to_symmetric_matrix(gamma)
- array([[1,2,3],
[2,4,5], [3,5,6]])
- RIFT.physics.effectiveFisher.effectiveFisher(residual_func, *flat_grids)
Fit a quadratic to the ambiguity function tabulated on a grid. Inputs:
a pointer to a function to compute residuals, e.g. z(x1, …, xN) - fit for N-dimensions, this is called ‘residualsNd’
N+1 flat arrays of length K. N arrays for each on N parameters, plus 1 array of values of the overlap
- Returns:
flat array of upper-triangular elements of the effective Fisher matrix
Example: x1s = [x1_1, …, x1_K] x2s = [x2_1, …, x2_K] … xNs = [xN_1, …, xN_K]
gamma = effectiveFisher(residualsNd, x1s, x2s, …, xNs, rhos) gamma
[g_11, g_12, …, g_1N, g_22, …, g_2N, g_33, …, g_3N, …, g_NN]
- RIFT.physics.effectiveFisher.eigensystem(matrix)
- Given an array-like ‘matrix’, returns:
An array of eigenvalues
An array of eigenvectors
- A rotation matrix that rotates the eigenbasis
into the original basis
- Example:
mat = [[1,2,3],[2,4,5],[3,5,6]] evals, evecs, rot = eigensystem(mat) evals
array([ 11.34481428+0.j, -0.51572947+0.j, 0.17091519+0.j]
- evecs
- array([[-0.32798528, -0.59100905, -0.73697623],
[-0.73697623, -0.32798528, 0.59100905], [ 0.59100905, -0.73697623, 0.32798528]])
- rot
- array([[-0.32798528, -0.73697623, 0.59100905],
[-0.59100905, -0.32798528, -0.73697623], [-0.73697623, 0.59100905, 0.32798528]]))
This allows you to translate between original and eigenbases:
If [v1, v2, v3] are the components of a vector in eigenbasis e1, e2, e3 Then:
rot.dot([v1,v2,v3]) = [vx,vy,vz]
Will give the components in the original basis x, y, z
If [wx, wy, wz] are the components of a vector in original basis z, y, z Then:
inv(rot).dot([wx,wy,wz]) = [w1,w2,w3]
Will give the components in the eigenbasis e1, e2, e3
- inv(rot).dot(mat).dot(rot)
- array([[evals[0], 0, 0]
[0, evals[1], 0] [0, 0, evals[2]]])
Note: For symmetric input ‘matrix’, inv(rot) == evecs
- RIFT.physics.effectiveFisher.evalfit2d(x1, x2, gamma)
- RIFT.physics.effectiveFisher.evalfit3d(x1, x2, x3, gamma)
- RIFT.physics.effectiveFisher.evalfit4d(x1, x2, x3, x4, gamma)
- RIFT.physics.effectiveFisher.evalfit5d(x1, x2, x3, x4, x5, gamma)
- RIFT.physics.effectiveFisher.evaluate_ip_on_grid(hfSIG, P, IP, param_names, grid)
Evaluate IP.ip(hsig, htmplt) everywhere on a multidimensional grid
- RIFT.physics.effectiveFisher.find_effective_Fisher_region(P, IP, target_match, param_names, param_bounds)
- Example Usage:
find_effective_Fisher_region(P, IP, 0.9, [‘Mc’, ‘eta’], [[mchirp(P.m1,P.m2)-lal.LAL_MSUN_SI,mchirp(P.m1,P.m2)+lal.LAL_MSUN_SI], [0.05, 0.25]])
- Arguments:
P: a ChooseWaveformParams object describing a target signal
- IP: An inner product class to compute overlaps.
Should have deltaF and length consistent with P
- target_match: find parameter variation where overlap is target_match.
Should be a real number in [0,1]
- param_names: array of string names for members of P to vary.
Should have length N for N params to be varied e.g. [‘Mc’, ‘eta’]
- param_bounds: array of max variations of each param in param_names
Should be an Nx2 array for N params to be varied
- Returns:
- Array of boundaries of a hypercube meant to encompass region where
match is >= target_match. e.g. [ [3.12,3.16] , [0.12, 0.18] ]
N.B. Only checks variations along parameter axes. If params are correlated, may get better matches off-axis, and the hypercube won’t fully encompass region where target_match is achieved. Therefore, allow a generous safety factor in your value of ‘target_match’.
- RIFT.physics.effectiveFisher.linear_spoked_ellipsoid(Nrad, Nspokes, start_angles, *radii)
Return an array of pts distributed uniformly inside a D-dimensional ellipsoid. D is determined by the number of radii args given.
- Output:
cart_pts: array of pts in Cartesian coordinates
- sph_pts: array of points in spherical coordinates
(r, zenith_1, .., zenith_N-2, azimuth)
- RIFT.physics.effectiveFisher.linear_spoked_ellipsoid2d(Nrad, Nspokes, th0, r1, r2)
2D case of function linear_spoked_ellipsoid
- RIFT.physics.effectiveFisher.make_regular_1d_grids(param_ranges, pts_per_dim)
- Inputs:
param_ranges is an array of parameter bounds, e.g.:
[ [p1_min, p1_max], [p2_min, p2_max], …, [pN_min, pN_max] ] - pts_per_dim is either:
an integer - use that many pts for every parameter
- an array of integers of same length as param_ranges, e.g.
[ N1, N2, …, NN ] the n-th entry is the number of pts for the n-th parameter
- Outputs:
outputs N separate 1d arrays of evenly spaced values of that parameter, where N = len(param_ranges)
- RIFT.physics.effectiveFisher.multi_dim_flatgrid(*arrs)
Creates flattened versions of meshgrids. Returns a tuple of arrays of values of individual parameters at each point in a grid, returned in a flat array structure.
e.g. x = [1,3,5] y = [2,4,6] X, Y = multi_dim_flatgrid(x, y) returns: X
[1,1,1,3,3,3,5,5,5]
- Y
[2,4,6,2,4,6,2,4,6]
- RIFT.physics.effectiveFisher.multi_dim_grid(*arrs)
Creates an array of values of all pts on a multidimensional grid.
e.g. x = [1,3,5] y = [2,4,6] multi_dim_grid(x, y) returns: [[1,2], [1,4], [1,6],
[3,2], [3,4], [3,6], [5,2], [5,4], [5,6]]
- RIFT.physics.effectiveFisher.multi_dim_meshgrid(*arrs)
Version of np.meshgrid generalized to arbitrary number of dimensions. Taken from: http://stackoverflow.com/questions/1827489/numpy-meshgrid-in-3d
- RIFT.physics.effectiveFisher.residuals2d(gamma, y, x1, x2)
- RIFT.physics.effectiveFisher.residuals3d(gamma, y, x1, x2, x3)
- RIFT.physics.effectiveFisher.residuals4d(gamma, y, x1, x2, x3, x4)
- RIFT.physics.effectiveFisher.residuals5d(gamma, y, x1, x2, x3, x4, x5)
- RIFT.physics.effectiveFisher.uniform_random_ellipsoid(Npts, *radii)
Return an array of pts distributed randomly and uniformly inside an D-dimensional ellipsoid. D is determined by the number of radii args given.
- Output:
cart_pts: array of pts in Cartesian coordinates
- sph_pts: array of points in spherical coordinates
(r, zenith_1, .., zenith_N-2, azimuth)
- RIFT.physics.effectiveFisher.uniform_random_ellipsoid2d(Npts, r1, r2)
2D case of uniform_random_ellipsoid
- RIFT.physics.effectiveFisher.uniform_random_ellipsoid3d(Npts, r1, r2, r3)
3D case of uniform_random_ellipsoid
- RIFT.physics.effectiveFisher.uniform_random_ellipsoid4d(Npts, r1, r2, r3, r4)
4D case of uniform_random_ellipsoid
- RIFT.physics.effectiveFisher.uniform_random_ellipsoid5d(Npts, r1, r2, r3, r4, r5)
5D case of uniform_random_ellipsoid
- RIFT.physics.effectiveFisher.uniform_spoked_ellipsoid(Nrad, Nspokes, start_angles, *radii)
Return an array of pts distributed uniformly inside a D-dimensional ellipsoid. D is determined by the number of radii args given.
- Output:
cart_pts: array of pts in Cartesian coordinates
- sph_pts: array of points in spherical coordinates
(r, zenith_1, .., zenith_N-2, azimuth)
- RIFT.physics.effectiveFisher.uniform_spoked_ellipsoid2d(Nrad, Nspokes, th0, r1, r2)
2D case of function uniform_spoked_ellipsoid
- RIFT.physics.effectiveFisher.update_params_ip(hfSIG, P, IP, param_names, vals)
Update the values of 1 or more member of P, recompute norm_hoff(P), and return IP.ip(hfSIG, norm_hoff(P))
- Inputs:
hfSIG: A COMPLEX16FrequencySeries of a fixed, unchanging signal
P: A ChooseWaveformParams object describing a varying template
IP: An InnerProduct object
- param_names: An array of strings of parameters to be updated.
e.g. [ ‘m1’, ‘m2’, ‘incl’ ]
- vals: update P to have these parameter values. Must have as many
vals as length of param_names, ordered the same way
- Outputs:
A COMPLEX16FrequencySeries, same as norm_hoff(P, IP)
- RIFT.physics.effectiveFisher.update_params_norm_hoff(P, IP, param_names, vals, verbose=False)
Update the values of 1 or more member of P and recompute norm_hoff(P).
- Inputs:
P: A ChooseWaveformParams object
IP: An InnerProduct object
- param_names: An array of strings of parameters to be updated.
e.g. [ ‘m1’, ‘m2’, ‘incl’ ]
- vals: update P to have these parameter values. Must be array-like
with same length as param_names, ordered the same way
- Outputs:
A COMPLEX16FrequencySeries, same as norm_hoff(P, IP)