numruby icon indicating copy to clipboard operation
numruby copied to clipboard

Random Engine

Open prasunanand opened this issue 6 years ago • 4 comments

Implement Random Engine generators

prasunanand avatar Aug 28 '19 10:08 prasunanand

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

pkspyder007 avatar Jan 23 '21 04:01 pkspyder007

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 ?

prasunanand avatar Jan 23 '21 04:01 prasunanand

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 avatar Jan 23 '21 15:01 pkspyder007

@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?

pkspyder007 avatar Feb 21 '21 10:02 pkspyder007