grand 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/core_ext/enumerable.rb +15 -0
- data/lib/grand.rb +17 -1
- data/lib/grand/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3586405a397dae7cf09dedc1cdcf61af9d38a1d6
|
4
|
+
data.tar.gz: f5292580efcfbbd668943f52c75dbb1b0d003927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b971c7b1225a2fa0f038f21200533cf6f1306968be069004e861ca6c3494d5d34870c79ff37b1d9692f54944795fbd2694e0412b1b0a1fd356c6e0a37a1cb885
|
7
|
+
data.tar.gz: 407cb1ee1815c078c10266d80ee6191543434e4745b6fc076dab4eb5a0b260f0a9d7bc40a32a19e81f2bf7b835f0b79de3d622b8be460da9befb791ad525dbc4
|
data/README.md
CHANGED
@@ -22,15 +22,15 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
> require 'grand'
|
24
24
|
=> true
|
25
|
-
> GRand
|
25
|
+
> GRand.randn
|
26
26
|
=> 0.8459468356387407
|
27
|
-
> GRand
|
27
|
+
> GRand.randn(1, 2)
|
28
28
|
=> [[-0.5259311445434742, 0.5058339155942712]]
|
29
|
-
> GRand
|
29
|
+
> GRand.rand(n3, 2)
|
30
30
|
=> [[1.0015454079393156, -0.2544992806165275], [-0.7978337095145441, -1.7813946216288779], [0.9631364295796622, 2.157358119782299]]
|
31
|
-
> GRand
|
31
|
+
> GRand.randn(2, 1)
|
32
32
|
=> [[-0.634759160869425], [0.549004503513128]]
|
33
|
-
> GRand
|
33
|
+
> GRand.randn(3, 3, 3)
|
34
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
|
data/lib/grand.rb
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
require 'grand/version'
|
2
2
|
require 'rubystats'
|
3
|
+
require 'matrix'
|
4
|
+
require 'core_ext/enumerable'
|
3
5
|
|
4
6
|
module GRand
|
7
|
+
def self.array_randn(*d)
|
8
|
+
return normal_distribution.rng if d.size == 0
|
9
|
+
|
10
|
+
x = d.shift
|
11
|
+
x.times.map{ self.array_randn(*d) }
|
12
|
+
end
|
13
|
+
|
5
14
|
def self.randn(*d)
|
6
15
|
return normal_distribution.rng if d.size == 0
|
7
16
|
|
8
17
|
x = d.shift
|
9
|
-
x.times.map{ self.randn(*d) }
|
18
|
+
Vector[*x.times.map{ self.randn(*d) }]
|
10
19
|
end
|
11
20
|
|
12
21
|
def self.normal_distribution
|
13
22
|
@@nd ||= Rubystats::NormalDistribution.new(0, 1)
|
14
23
|
end
|
24
|
+
|
25
|
+
def self.zeros(*d)
|
26
|
+
return 0 if d.size == 0
|
27
|
+
|
28
|
+
x = d.shift
|
29
|
+
Vector[*x.times.map{ self.zeros(*d) } ]
|
30
|
+
end
|
15
31
|
end
|
data/lib/grand/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Ostermayr
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubystats
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
85
|
- grand.gemspec
|
86
|
+
- lib/core_ext/enumerable.rb
|
86
87
|
- lib/grand.rb
|
87
88
|
- lib/grand/version.rb
|
88
89
|
homepage: https://github.com/gregors/grand
|
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
105
|
version: '0'
|
105
106
|
requirements: []
|
106
107
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.4.5
|
108
109
|
signing_key:
|
109
110
|
specification_version: 4
|
110
111
|
summary: I needed randn from numpy in ruby.
|