#ifndef PYTHONIC_NUMPY_RANDOM_F_HPP #define PYTHONIC_NUMPY_RANDOM_F_HPP #include "pythonic/include/numpy/random/f.hpp" #include "pythonic/include/numpy/random/generator.hpp" #include "pythonic/types/ndarray.hpp" #include "pythonic/types/NoneType.hpp" #include "pythonic/types/tuple.hpp" #include "pythonic/utils/functor.hpp" #include #include PYTHONIC_NS_BEGIN namespace numpy { namespace random { template types::ndarray f(double dfnum, double dfden, pS const &shape) { types::ndarray result{shape, types::none_type()}; std::chi_squared_distribution distribution{dfnum}; std::chi_squared_distribution distribution2{dfden}; std::generate(result.fbegin(), result.fend(), [&]() { return (distribution(details::generator) * dfden) / (distribution2(details::generator) * dfnum); }); return result; } auto f(double dfnum, double dfden, long size) -> decltype(f(dfnum, dfden, types::array{{size}})) { return f(dfnum, dfden, types::array{{size}}); } double f(double dfnum, double dfden, types::none_type d) { return (std::chi_squared_distribution{dfnum}(details::generator) * dfden) / (std::chi_squared_distribution{dfden}(details::generator) * dfnum); } } } PYTHONIC_NS_END #endif