rust-ndarray / ndarray-stats

Statistical routines for ndarray
https://docs.rs/ndarray-stats
Apache License 2.0
201 stars 25 forks source link

How to use the histogram if the min/max is not known on compile time? #67

Open selvavm opened 4 years ago

selvavm commented 4 years ago

I am not sure if this is a right place to ask this question. First, thanks for your contribution. I am having n time series of Vec<f32> and I want to get a histogram Count of m (usually 50) bins. In python, there is a possibility to say the number of bins needed and is it possible to do in rust?

My next problem is, I don’t know the observation values during compile time so I can’t build the grid beforehand. Is it possible to redefine the grid once added.

For example, I initiate an empty histogram, and add observations in a loop ( the loop will be a concat of multiple time series until merge pr is ready :) ). Then I say the bin count (say 50). It should distribute the bin range with 50 bins based on the min/max. Is this possible?

My use case can be solved using HdrHistogram but it supports only u64 and not f32. Also, in my application I already use ndarray, so felt this crate will fit very well.

Note: I am new to rust

nilgoyette commented 3 years ago

Sorry for the late answer (6 months later). If it's too late or you have found a solution, can you please close this issue?

I have never used Histogram myself, but looking at this example, there's nothing that need to be "hardcoded" or set at "compile time". The example does show only n64 floats, but noisy_float also provides n32.