This may be what you require:

https://commons.apache.org/proper/commons-math/javadocs/api-4.0-beta1/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.html

You will have to convert your float values to double and then specify
the bin size:

float[] x = ...
int bins = 100;
ContinuousDistribution d = EmpiricalDistribution.from(bins,
    IntStream.range(0, x.length).mapToDouble(i -> x[i]).toArray());

On Fri, 29 Sept 2023 at 17:44, Siddharth Jain <siddh...@gmail.com> wrote:
>
> I have a vector float[] x containing samples of a random variable. I would
> like to initialize a prob. distribution fn. using these samples and then be
> able to call methods like
> https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/org/apache/commons/statistics/distribution/ContinuousDistribution.html
>
> I am looking for an API like:
>
> var f = ContinuousDistribution.of(x)
>
> is this available in commons-math? thanks.
>
> S.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to