Ideal and robust soliton distribution#119
Ideal and robust soliton distribution#119refugeesus wants to merge 4 commits intostatrs-dev:masterfrom
Conversation
| /// The 'IdealSoliton' trait provides an interface for interacting | ||
| /// with discrete statistical distributions from integers 1..N with | ||
| /// N as the single parameter for the distribution | ||
| pub trait Soliton<T, K> { |
There was a problem hiding this comment.
Traits are often, but not always, a contract on types one does not yet know about. In this case the trait is superfluous, as there only seem to be two soliton distributions, both of which are provided.
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq)] | ||
| pub struct RobustSolitonDistribution { |
There was a problem hiding this comment.
This struct seems forgotten code after a refactor? It's not used anywhere and has no constructor, but private fields.
There was a problem hiding this comment.
Yep, missed this. Will remove.
| if max < 1 { | ||
| Err(StatsError::BadParams) | ||
| } else { | ||
| let pmf_table: Vec<f64> = Vec::with_capacity(max as usize); |
There was a problem hiding this comment.
This type is inferred and can be elided.
|
|
||
| impl Distribution<f64> for RobustSoliton { | ||
| fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64 { | ||
| r.gen_range(0, 1) as f64 |
| } | ||
|
|
||
| impl IdealSoliton { | ||
| /// Constructs a new discrete uniform distribution with a minimum value |
There was a problem hiding this comment.
There are seven doc strings referencing the discrete uniform distribution instead of the (ideal|robust) soliton distribution.
There was a problem hiding this comment.
Forgot to update this as had been done in robust soliton. 👍
| fn mean(&self) -> f64 { | ||
| let sum: f64 = Iterator::sum(self.cumulative_probability_table.iter()); | ||
| let mean = sum / self.cumulative_probability_table.len() as f64; | ||
| mean |
There was a problem hiding this comment.
This would be clearer as .iter().sum()
Can you explain how this calculation works? As far as I know, there are two equivalent formulas for calculating the mean: Sum(n*p(n)) or when using cumulative probability Sum(P(X>n)) = Sum(1-P(X<=n)) = Sum(1-CPF(n))
I do not see either of them being used here.
Hello all.
I have added in an implementation for the ideal and robust soliton distributions which are required in ECC and coding method implementations I am working on. To my knowledge these are correctly implemented as the libraries I utilize them in function as expected in their tests.
There are likely methods which should be implemented for the purposes of this library which I have not completed, and if so, I would be happy to complete them so this can be merged appropriately. I hope this has been added in appropriately, as it is a bit of an odd implementation of discrete uniform distributions. If the structure should change it would be helpful to have some guidance for what is best.