pub struct Builder { /* private fields */ }
Expand description
options in precedence order:
As of 0.2.0: Specify the number symbols excluding the EOF symbol. If you specify an EOF it will automatically increase symbol count by one for the EOF. (or else choose value in range). See the setter for EOF for more detail.
- counts
- eof?
- pdf
- eof?
- scale?
- symbol count
- symbol count
- eof?
- binary - default but can also be explicit
You should only use one of the build paths
Implementations§
Source§impl Builder
impl Builder
pub fn new() -> Self
pub fn num_symbols(&mut self, count: u32) -> &mut Self
pub fn num_bits(&mut self, size: u32) -> &mut Self
Sourcepub fn counts(&mut self, counts: Vec<u32>) -> &mut Self
pub fn counts(&mut self, counts: Vec<u32>) -> &mut Self
Constructs new model if you already have counts present.
Implied number of symbols from length of counts
.
Sourcepub fn eof(&mut self, eof: EOFKind) -> &mut Self
pub fn eof(&mut self, eof: EOFKind) -> &mut Self
- Specify(u32): Choose a valid index as the EOF
[0, counts.len())
- Start: index 0
- End: index
counts.len()
- 1 - EndAddOne: adds an element to
counts
and sets EOF tocounts.len() - 1
- None: Same as not specifying. Sets to value outside symbol rangec
Sourcepub fn scale(&mut self, scale: u32) -> &mut Self
pub fn scale(&mut self, scale: u32) -> &mut Self
value = (p * scale)
Therefore besides determining the accuracy, scale is used to determine the elasticity of the model.
Sourcepub fn pdf(&mut self, pdf: Vec<f32>) -> &mut Self
pub fn pdf(&mut self, pdf: Vec<f32>) -> &mut Self
constructs a new source_model given a vector of probabilities where the length is the number of symbols (min 10). Defaults scale to length of pdf.
Open to suggestions for default scale This method will not panic on negative values or values greater than 1.0. They dont cause mathematical errors so its on the user to use probabilities correctly.