Not sure what you mean by "density" value? Do you mean the frequency of a value in a given set? Since these are `f64`

s, you can have rounding errors, hence I cast to integers so that it additionally satisfies `Eq`

:

```
use std::collections::HashMap;
const SCALE: f64 = 1.0;
fn main() {
let given_slice: &[f64] = &[1., 2., 3.];
let mut hashmap = HashMap::<i128, usize>::new();
given_slice
.iter()
.for_each(
|x| {
let rounded = (x * SCALE) as i128;
*hashmap
.entry(rounded)
.or_insert(0)
+= 1;
}
);
}
```

If you mean something more like calculating the values between the ticks on the Y-axis, then something like this would work:

```
const NUM_TICKS: f64 = 10.0;
fn main() {
let given_slice: &[f64] = &[1., 2., 3.];
let mut max = f64::MIN;
let mut min = f64::MAX;
given_slice
.iter()
.copied()
.for_each(|x| {
if x > max {
max = x;
}
if x < min {
min = x;
}
});
let size = max - min;
let distance_ticks = size / NUM_TICKS;
println!("{}", distance_ticks);
}
```

If I completely misinterpreted your question, please let me know!