estimator.nd.SparseTernary#
- class estimator.nd.SparseTernary(p, m=None, n=None)[source]#
Distribution of vectors of length
n
withp
entries of 1 andm
entries of -1, rest 0.EXAMPLE:
>>> from estimator import * >>> ND.SparseTernary(10, n=100) T(p=10, m=10, n=100) >>> ND.SparseTernary(10, 10, 100) T(p=10, m=10, n=100) >>> ND.SparseTernary(10, 8, 100) T(p=10, m=8, n=100) >>> ND.SparseTernary(0, 0, 0).support_size() 1
- __call__(**kwargs)#
Call self as a function.
Methods
__init__
(p[, m, n])resize
(new_n)Return an altered distribution having a dimension new_n.
split_balanced
(new_n[, new_hw])Split the +1 and -1 entries in a balanced way, and return 2 SparseTernary distributions: one of dimension new_n and the other of dimension n - new_n.
split_probability
(new_n[, new_hw])Compute probability of splitting in a way that one half having new_n coefficients has new_hw of the weight, and the remaining part the rest.
support_size
([fraction])Compute the size of the support covering the probability given as fraction.
Attributes
The number of non-zero coefficients in this distribution
Whether the value of coefficients are bounded
Always say this is a sparse distribution, even if p + m >= n/2, because there is correlation between the coefficients: if you split the distribution into two of half the length, then you expect in each of them to be half the weight.