Distributions
Abstract Types
RLinearAlgebra.Distribution
— TypeDistribution
An abstract supertype for structures specifying distribution for indices in sampling methods.
RLinearAlgebra.DistributionRecipe
— TypeDistributionRecipe
An abstract supertype for structures with pre-allocated memory for distribution function sampling methods.
Distribution Structures
RLinearAlgebra.Uniform
— TypeUniform <: Distribution
Uniform distribution over the row/column index set of a matrix.
Mathematical Description
During the sampling, the uniform distribution is defined on the domain of row/column indices. If it's compressing from the left, then it means every row index has the same probability weight. If it's compressing from the right, then it means every column index has the same probability weight.
Fields
cardinality::Cardinality
, the direction the compression matrix is intended to be applied to a target matrix or operator. Values allowed areLeft()
orRight()
orUndef()
.replace::Bool
, iftrue
, then the sampling occurs with replacement; iffalse
, then the sampling occurs without replacement.
Constructor
Uniform(;cardinality=Undef(), replace = false)
Returns
- A
Uniform
object.
RLinearAlgebra.UniformRecipe
— TypeUniformRecipe <: DistributionRecipe
The recipe containing all allocations and information for the uniform distribution.
Fields
cardinality::C where C<:Cardinality
, the cardinality of the compressor. The value is eitherLeft()
orRight()
orUndef()
.replace::Bool
, an option to replace or not during the sampling process based on the given weights.state_space::Vector{Int64}
, the row/column index set.weights::ProbabilityWeights
, the weights of each element in the state space.
Exported Functions
RLinearAlgebra.complete_distribution
— Functioncomplete_distribution(distribution::Distribution, A::AbstractMatrix)
A function that generates a DistributionRecipe
given the arguments.
Arguments
distribution::Distribution
, a user-specified distribution function for sampling.A::AbstractMatrix
, a coefficient matrix.
Outputs
- A
DistributionRecipe
object.
RLinearAlgebra.update_distribution!
— Functionupdate_distribution!(distribution::DistributionRecipe, A::AbstractMatrix)
A function that updates the DistributionRecipe
in place given arguments.
Arguments
distribution::DistributionRecipe
, a fully initialized realization of distribution.A::AbstractMatrix
, a coefficient matrix.
Outputs
- Modifies the
DistributionRecipe
in place and returns nothing.
RLinearAlgebra.sample_distribution!
— Functionsample_distribution!(x::AbstractVector, distribution::DistributionRecipe)
A function that in place updates the x
by given DistributionRecipe
info.
Arguments
x::AbstractVector
, an abstract vector to store the sampled indices.distribution::DistributionRecipe
, a fully initialized realization of distribution.
Outputs
- Modifies the
x
in place by sampling that follows the weights and replacement given by
'DistributionRecipe'.