affine.multiscale¶
Module: affine.multiscale
¶
Inheritance diagram for regreg.affine.multiscale
:
Class¶
multiscale
¶
-
class
regreg.affine.multiscale.
multiscale
(p, minsize=None, slices=[], scaling=None)¶ Bases:
regreg.affine.affine_transform
An affine transform representing the multiscale changepoint transform.
This transform centers the input and then computes the average over all intervals of a minimum size.
-
__init__
(p, minsize=None, slices=[], scaling=None)¶ - Parameters
p : int
Length of signal.
minsize : int
Smallest interval to consider. Defaults to p**(1/3.)
slices : []
A list of intervals to use in the transform. Will be coerced to have dtype([(‘start’, np.int), (‘end’, np.int)])
scaling : np.float((slices.shape))
An optional scaling to apply after computing mean over each interval.
-
property
T
¶
-
adjoint_map
(v)¶ - Parameters
v : np.float(self.output_shape)
- Returns
v : np.float(self.input_shape)
-
affine_map
(x)¶ Apply linear and affine offset to x
Return \(Dx+\alpha\)
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
copy : {True, False}, optional
If True, in situations where return is identical to x, ensure returned value is a copy.
- Returns
Dx_a : ndarray
x transformed with linear and offset components
Notes
This routine is subclassed in affine_atom as a matrix multiplications, but could also call FFTs if D is a DFT matrix, in a subclass.
-
dot
(x)¶ Apply linear part of transform to x. Returns self.linear_map(x) unless x is a transform, in which case it returns the composition.
- Parameters
x : ndarray
array to which to apply transform. Can be 1D or 2D
- Returns
Dx : ndarray
x transformed with linear component
-
dtype
= dtype([('start', '<i8'), ('end', '<i8')])¶
-
form_matrix
(slices)¶ Form a matrix with given slices of multiscale transform.
-
linear_map
(x)¶ Given a p-vector x compute the average of x - x.mean() over each interval of size greater than self.minsize.
- Parameters
x : np.float(self.input_shape)
- Returns
v : np.float(self.output_shape)
-
property
ndim
¶
-
property
shape
¶
-
update_slices
(slices, scaling=None)¶ Change the intervals computed by the multiscale transform.
- Parameters
slices : []
List of (i,j) intervals to compute. Will be converted to have dtype([(‘start’, np.int), (‘end’, np.int)])
-
Functions¶
-
regreg.affine.multiscale.
SMUCE_stat
(M, Z, sigma=None)¶ Compute multiscale test statistic of Chan and Walther. Used in the SMUCE algorithm and in the multiscale change point algorithm in the square-root LASSO selective inference paper.
- Parameters
M : instance of multiscale
Z : np.ndarray
Data on which to compute the statistic.
sigma : float
Noise level. Defaults to np.std(Z).
Notes
M’s scaling is ignored, even if not None.
-
regreg.affine.multiscale.
choose_tuning_parameter
(M, ndraw=100, quantile=0.95, sigma=None)¶ Choose tuning parameter in the SMUCE algorithm and in the multiscale change point algorithm in the square-root LASSO selective inference paper.
- Parameters
M : instance of multiscale
ndraw : int
How many Monte Carlo draws.
quantile : float
Which quantile of Monte Carlo draws to choose.
sigma : float
Passed to SMUCE_stat
Notes
M’s scaling is ignored, even if not None.