grand 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/lib/grand/version.rb +1 -1
- data/lib/grand.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79966081fc76d3aa05452572e08c7c2a993ec01e
|
4
|
+
data.tar.gz: 6ceeb90e5a9262cb773301684c97bc85b391c8c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e08c56d809188e322881e4e6f5d572e3d476824c09c372fbd67625e725e8521f613d6f7d9ba9322e58948142abb5916a83c150c0d36f194d314ffa014a8ad6
|
7
|
+
data.tar.gz: 3bf5b3959ddec40e8e5315eb73aeefa1aeb19e27165a76b8758789127147d7e2bf86bea7d49c5e3d04c6f4a521a7f5f672eceeef1352e79cb0e6c324d132a0c0
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# GRand
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/grand`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
3
|
I needed something similar to `nrand` in numpy. see - https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.randn.html
|
6
4
|
|
7
5
|
## Installation
|
@@ -23,15 +21,17 @@ Or install it yourself as:
|
|
23
21
|
## Usage
|
24
22
|
|
25
23
|
> require 'grand'
|
26
|
-
|
27
|
-
> GRand::
|
28
|
-
=>
|
29
|
-
> GRand::
|
30
|
-
=> [[
|
31
|
-
> GRand::
|
32
|
-
=> [[-0.
|
33
|
-
> GRand::
|
34
|
-
=> [[
|
24
|
+
=> true
|
25
|
+
> GRand::randn
|
26
|
+
=> 0.8459468356387407
|
27
|
+
> GRand::randn(1, 2)
|
28
|
+
=> [[-0.5259311445434742, 0.5058339155942712]]
|
29
|
+
> GRand::rand(n3, 2)
|
30
|
+
=> [[1.0015454079393156, -0.2544992806165275], [-0.7978337095145441, -1.7813946216288779], [0.9631364295796622, 2.157358119782299]]
|
31
|
+
> GRand::randn(2, 1)
|
32
|
+
=> [[-0.634759160869425], [0.549004503513128]]
|
33
|
+
> GRand::randn(3, 3, 3)
|
34
|
+
=> [[[-1.689589847133065, -0.41054654640696786, 0.36381728856120105], [-0.9437196021569799, 1.19558636009585, -1.1605453269136559], [1.0837506708104712, -1.1395537425254014, 0.5925022408229144]], [[-1.7133014088074843, -0.805051352081152, 0.3746241803203248], [0.3642622933280586, 0.5843943798812012, 1.141236536447513], [-0.25543269419159714, 1.1743836190357984, -0.5161554049975062]], [[-0.03303459622587511, -3.5547854922416438, 0.17581738567933877], [-0.979119743081027, 1.397273496753393, 0.18670646583239753], [-0.26985128879011183, -0.5662975999343106, 0.46600852896034334]]]
|
35
35
|
|
36
36
|
## Development
|
37
37
|
|
data/lib/grand/version.rb
CHANGED
data/lib/grand.rb
CHANGED
@@ -2,11 +2,11 @@ require 'grand/version'
|
|
2
2
|
require 'rubystats'
|
3
3
|
|
4
4
|
module GRand
|
5
|
-
def self.
|
5
|
+
def self.randn(*d)
|
6
6
|
return normal_distribution.rng if d.size == 0
|
7
7
|
|
8
8
|
x = d.shift
|
9
|
-
x.times.map{ self.
|
9
|
+
x.times.map{ self.randn(*d) }
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.normal_distribution
|