Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing numpy.random distributions #1343

Merged
merged 1 commit into from Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/chisquare.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_CHISQUARE_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_CHISQUARE_HPP

#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/tuple.hpp"
#include "pythonic/include/utils/functor.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> chisquare(float df, pS const &shape);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/float/double/ ?


auto chisquare(float df, long size)
-> decltype(chisquare(df, types::array<long, 1>{{size}}));

double chisquare(float df, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, chisquare);
}
}
PYTHONIC_NS_END

#endif
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/dirichlet.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_DIRICHLET_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_DIRICHLET_HPP

#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/tuple.hpp"
#include "pythonic/include/utils/functor.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> dirichlet(double alpha, pS const &shape);

auto dirichlet(double alpha, long size)
-> decltype(dirichlet(alpha, types::array<long, 1>{{size}}));

double dirichlet(double alpha, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, dirichlet);
}
}
PYTHONIC_NS_END

#endif
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/exponential.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_EXPONENTIAL_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_EXPONENTIAL_HPP

#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/tuple.hpp"
#include "pythonic/include/utils/functor.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> exponential(double scale, pS const &shape);

auto exponential(double scale, long size)
-> decltype(exponential(scale, types::array<long, 1>{{size}}));

double exponential(double scale = 1.0, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, exponential);
}
}
PYTHONIC_NS_END

#endif
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/f.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_F_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_F_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> f(double dfnum, double dfden, pS const &shape);

auto f(double dfnum, double dfden, long size)
-> decltype(f(dfnum, dfden, types::array<long, 1>{{size}}));

double f(double dfnum, double dfden, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, f);
}
}
PYTHONIC_NS_END

#endif
29 changes: 29 additions & 0 deletions pythran/pythonic/include/numpy/random/gamma.hpp
@@ -0,0 +1,29 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_GAMMA_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_GAMMA_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> gamma(double shape, double scale,
pS const &array_shape);

auto gamma(double shape, double scale, long size)
-> decltype(gamma(shape, scale, types::array<long, 1>{{size}}));

double gamma(double shape = 0.0, double scale = 1.0,
types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, gamma);
}
}
PYTHONIC_NS_END

#endif
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/geometric.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_GEOMETRIC_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_GEOMETRIC_HPP

#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/tuple.hpp"
#include "pythonic/include/utils/functor.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> geometric(double p, pS const &shape);

auto geometric(double p, long size)
-> decltype(geometric(p, types::array<long, 1>{{size}}));

double geometric(double, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, geometric);
}
}
PYTHONIC_NS_END

#endif
29 changes: 29 additions & 0 deletions pythran/pythonic/include/numpy/random/gumbel.hpp
@@ -0,0 +1,29 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_GUMBEL_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_GUMBEL_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> gumbel(double loc, double scale,
pS const &shape);

auto gumbel(double loc, double scale, long size)
-> decltype(gumbel(loc, scale, types::array<long, 1>{{size}}));

double gumbel(double loc = 0.0, double scale = 1.0,
types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, gumbel);
}
}
PYTHONIC_NS_END

#endif
29 changes: 29 additions & 0 deletions pythran/pythonic/include/numpy/random/laplace.hpp
@@ -0,0 +1,29 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_LAPLACE_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_LAPLACE_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> laplace(double loc, double scale,
pS const &shape);

auto laplace(double loc, double scale, long size)
-> decltype(laplace(loc, scale, types::array<long, 1>{{size}}));

double laplace(double loc = 0.0, double scale = 1.0,
types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, laplace);
}
}
PYTHONIC_NS_END

#endif
29 changes: 29 additions & 0 deletions pythran/pythonic/include/numpy/random/logistic.hpp
@@ -0,0 +1,29 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGISTIC_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGISTIC_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> logistic(double loc, double scale,
pS const &shape);

auto logistic(double loc, double scale, long size)
-> decltype(logistic(loc, scale, types::array<long, 1>{{size}}));

double logistic(double loc = 0.0, double scale = 1.0,
types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, logistic);
}
}
PYTHONIC_NS_END

#endif
29 changes: 29 additions & 0 deletions pythran/pythonic/include/numpy/random/lognormal.hpp
@@ -0,0 +1,29 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGNORMAL_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGNORMAL_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> lognormal(double mean, double sigma,
pS const &shape);

auto lognormal(double mean, double sigma, long size)
-> decltype(lognormal(mean, sigma, types::array<long, 1>{{size}}));

double lognormal(double mean = 0.0, double sigma = 1.0,
types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, lognormal);
}
}
PYTHONIC_NS_END

#endif
27 changes: 27 additions & 0 deletions pythran/pythonic/include/numpy/random/logseries.hpp
@@ -0,0 +1,27 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGSERIES_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_LOGSERIES_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> logseries(double loc, pS const &shape);

auto logseries(double loc, long size)
-> decltype(logseries(loc, types::array<long, 1>{{size}}));

double logseries(double loc, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, logseries);
}
}
PYTHONIC_NS_END

#endif
28 changes: 28 additions & 0 deletions pythran/pythonic/include/numpy/random/negative_binomial.hpp
@@ -0,0 +1,28 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_NEGATIVE_BINOMIAL_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_NEGATIVE_BINOMIAL_HPP

#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/tuple.hpp"

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> negative_binomial(double n, double p,
pS const &shape);

auto negative_binomial(double n, double p, long size)
-> decltype(negative_binomial(n, p, types::array<long, 1>{{size}}));

double negative_binomial(double n, double p, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, negative_binomial);
}
}
PYTHONIC_NS_END

#endif
28 changes: 28 additions & 0 deletions pythran/pythonic/include/numpy/random/pareto.hpp
@@ -0,0 +1,28 @@
#ifndef PYTHONIC_INCLUDE_NUMPY_RANDOM_PARETO_HPP
#define PYTHONIC_INCLUDE_NUMPY_RANDOM_PARETO_HPP

#include "pythonic/include/types/NoneType.hpp"
#include "pythonic/include/types/ndarray.hpp"
#include "pythonic/include/types/tuple.hpp"
#include "pythonic/include/utils/functor.hpp"
#include <math.h>

PYTHONIC_NS_BEGIN
namespace numpy
{
namespace random
{
template <class pS>
types::ndarray<double, pS> pareto(double a, pS const &shape);

auto pareto(double a, long size)
-> decltype(pareto(a, types::array<long, 1>{{size}}));

double pareto(double a, types::none_type size = {});

DEFINE_FUNCTOR(pythonic::numpy::random, pareto);
}
}
PYTHONIC_NS_END

#endif