Giter Site home page Giter Site logo

probability's People

Contributors

hpux735 avatar imbaczek avatar ivanukhov avatar jonls avatar knappador avatar robamler avatar runarberg avatar therustmonk avatar yukinagae avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

probability's Issues

PartialOrd behaviour

Lib contains comparsions like:

impl distribution::Continuous for Exponential {
    #[inline]
    fn density(&self, x: f64) -> f64 {
        if x < 0.0 {
            0.0
        } else {
            self.lambda * (-self.lambda * x).exp()
        }
    }
}

but in fact f64 implements PartialOrd only and comparsion contains some uncontrolled behaviour:

if x < 0.0 {
    0.0
} else {   // x >= 0.0 && x.is_nan()
    self.lambda * (-self.lambda * x).exp()
}

What about to use PartialCmp explicitly? I think It won't decline perfomance.

Case in which Newton method for Binomial::inverse does not converge

The following test results in an infinite loop in version 0.18 due to the Newton method not converging.

#[test]
fn inverse_non_converging() {
    let p = 0.9810204628647335;
    let n = 3666;
    let q = 0.0033333333333332993;

    let dist = Binomial::new(n, p);
    let k = dist.inverse(q);

    println!("k = {k}");
}

RFC: Make parameters private

Should the parameters of a distribution be private?

Pros:

  1. The internal state of a distribution is protected.

Cons:

  1. One has to provide getters.
  2. One has to type two additional characters, that is, (), to access a parameter.
  3. Once created, a distribution cannot change (unless setters are provided as well).

Support definitions

Hi Ivan,

I've been working on some research using Rust and started programming a distributions/probability toolbox before realising you'd already done the job for me. One thing, however, that would be really useful is if each distribution not only defined what values it returns when sampling, but also the support over which it is defined. I originally did this by adding an associated type bound to take values implementing the Space trait in my spaces crate.

Is this a feature you'd be happy to add? I'd be more than happy to actually code it up and contribute; not necessarily using my spaces code mind.

Let me know what you think.

Regards,
Tom

Add more distributions

@IvanUkhov Your library is great! Good test coverage. I like it 👍
What about to add more features? I can help with PRs.

I've found a distributions list there.

  • Bernoulli
  • Beta
  • Binomial
  • Categorical
  • Exponential
  • Gamma
  • Gaussian
  • Logistic
  • Lognormal
  • Triangular
  • Uniform
  • Chi-Square
  • Poisson
  • Erlang
  • Student’s t
  • Weibull
  • Geometric
  • Pareto
  • Hypergeometric
  • Extreme Value
  • Negative Binomial
  • Cumulative
  • Error Function
  • General
  • Histogram
  • Inverse Gaussian
  • IntUniform
  • Log-Logistic
  • Lognormal2
  • Pareto2
  • Pearson V
  • Pearson VI
  • PERT
  • Rayleigh
  • Beta-Subjective
  • Trigen

What do you think about this list?

I already have implementations of some with C and want to move it to Rust and found your library is the best place to do it. What about to implement most of them?

Implementing default trait for distribution types

Hey! I wanted to ask if you'd be open to merging a change that adds default implementations for various distributions? I've been using your crate and would like to implement default so that types that wrap the raw distributions can be made a bit more ergonomic for things like examples / tests etc.

Laplace Distribution

Wikipedia's definition looks pretty straightforward. I started work by copying the exponential.rs and just replacing formulas.

What's the scope of work that needs to be done on all new distributions?

RFC: Separate distributions into discrete and continuous

Should there be a clear separation of distributions into discrete and continuous?

Related thoughts and questions:

  1. What is the main motivation for the separation? Any use cases?
  2. Should the separation be based on modules, traits, or both?
  3. What happens to those that are neither discrete nor continuous?
  4. Except from uniforms, are there any other name clashes?

Add support to derive distribution properties from iterators

This package is great, and it's most of what I need. However, there doesn't seem to be a way to give it an iterator and have it derive the distribution coefficients. For example, if you created a new Gaussian distribution, you could initialize it with an iterator over f64 and it would traverse the iterator and compute the mean and variance, which could then be used in later computation.

If there is interest in such a feature from the maintainer(s), and a desire to help shape the architecture of such a feature, I could take a crack at implementing it...

Let me know.

Thanks.

Add `new_with_check` methods to distributions

There aren't constructors which returns Result<Self, Error>. It's useful for software where user can set parameters for distributions. Without this kind of methods I have to repeat checks. For release the checking is lost at all. Library uses debug_assert which can panic during testing, but it's better to provide explicit behaviour.

I offer to add something like this:

// categorical.rs

pub enum Error {
    LessThanZero,
    GreaterThanOne,
    SumNotEqualOne,
}

impl Categorical {
    pub fn new_with_check(p: &[f64]) -> Result<Self, Error>;
}

@IvanUkhov Your opinion?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.