pub fn new(weights: Vec<f64>, intervals: Vec<f64>) -> Result<Self> {
        let mut weights = weights;
        if weights.len() == 0 {
            bail!(EmptyWeightError);
        }
        if weights.iter().all(|&x| x == 0f64) {
            bail!(AllZeroWeightError);
        }
        let mut intervals = auto_zip(&intervals);
        if weights.len() != intervals.len() {
            bail!(LengthMismatchError);
        }

        // Remove zero weights & corresponding intervals
        let mut i = 0;
        let mut j = weights.len();
        while i < j {
            if weights[i] == 0f64 {
                weights.remove(i);
                intervals.remove(i);
                j -= 1;
            } else {
                i += 1;
            }
        }

        let sum = weights
            .iter()
            .zip(intervals.iter())
            .fold(0f64, |acc, (w, (a, b))| acc + w * (b - a));

        Ok(WeightedUniform {
            weights,
            sum,
            intervals,
        })
    }
Create a new weighted uniform distribution

# Examples
```
use peroxide::fuga::*;

fn main() -> Result<(), Box<dyn Error>> {
let weights = vec![1f64, 3f64, 0f64, 2f64];
let intervals = vec![0f64, 1f64, 2f64, 4f64, 5f64];
let w = WeightedUniform::new(weights, intervals)?;
assert_eq!(w.weights(), &vec![1f64, 3f64, 2f64]);
assert_eq!(w.intervals(), &vec![(0f64, 1f64), (1f64, 2f64), (4f64, 5f64)]);

Ok(())
}
```
src/statistics/dist.rs