SciRuby / numruby

Fast Numerical Linear Algebra Library for Ruby. NMatrix reimplementation.
BSD 3-Clause "New" or "Revised" License
45 stars 10 forks source link

Random Engine #33

Open prasunanand opened 5 years ago

prasunanand commented 5 years ago

Implement Random Engine generators

pkspyder007 commented 3 years ago

@prasunanand could you please explain this feature and some guidelines how to implement it.

prasunanand commented 3 years ago

Please take a look at different generators in numpy code base.

http://www.netlib.org/lapack/explore-html/df/dd1/group___o_t_h_e_rauxiliary_ga77e05a87ced667cbdb502aa87c72d056.html https://github.com/numpy/numpy/tree/master/numpy/random

Describe an approach how you will implement it ?

pkspyder007 commented 3 years ago

The random module in NumPy has random generators such as random.uniform for uniform distribution, random.randn for normal distribution, and also range based pseudo-random generators.

What I am thinking is of a nested class in NumRuby that will bind to the native C functions for the various random generators. We also need to consider various data types we need to support for example bool, int, and float. For this, we can have overloaded functions, for distributions, I need to study how to create uniform/normal distributions in C.

class Random
 -> uniform(n, interval) => [ ...n ]
 -> normal(n, mean, sd) => [ ...n ]
 -> in_range(min, max) => n in [min, max)
etc
pkspyder007 commented 3 years ago

@prasunanand I am getting an error when I try to call LAPACK_dlarnv subroutine ( undefined reference to dlarnv ) Is there any specific way to call these functions in our ext folder?