tomoto 0.1.4 → 0.2.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/CHANGELOG.md +5 -0
- data/ext/tomoto/ct.cpp +8 -4
- data/ext/tomoto/dmr.cpp +10 -4
- data/ext/tomoto/dt.cpp +13 -4
- data/ext/tomoto/extconf.rb +1 -1
- data/ext/tomoto/gdmr.cpp +14 -6
- data/ext/tomoto/hdp.cpp +9 -4
- data/ext/tomoto/hlda.cpp +9 -4
- data/ext/tomoto/hpa.cpp +9 -4
- data/ext/tomoto/lda.cpp +8 -4
- data/ext/tomoto/llda.cpp +8 -4
- data/ext/tomoto/mglda.cpp +11 -1
- data/ext/tomoto/pa.cpp +9 -4
- data/ext/tomoto/plda.cpp +8 -4
- data/ext/tomoto/slda.cpp +13 -5
- data/lib/tomoto/gdmr.rb +2 -2
- data/lib/tomoto/version.rb +1 -1
- data/vendor/EigenRand/EigenRand/Core.h +6 -1107
- data/vendor/EigenRand/EigenRand/Dists/Basic.h +490 -43
- data/vendor/EigenRand/EigenRand/Dists/Discrete.h +916 -285
- data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +85 -36
- data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +1038 -290
- data/vendor/EigenRand/EigenRand/EigenRand +2 -2
- data/vendor/EigenRand/EigenRand/Macro.h +4 -4
- data/vendor/EigenRand/EigenRand/MorePacketMath.h +54 -22
- data/vendor/EigenRand/EigenRand/MvDists/Multinomial.h +222 -0
- data/vendor/EigenRand/EigenRand/MvDists/MvNormal.h +492 -0
- data/vendor/EigenRand/EigenRand/PacketFilter.h +2 -2
- data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +2 -2
- data/vendor/EigenRand/EigenRand/RandUtils.h +65 -11
- data/vendor/EigenRand/EigenRand/doc.h +142 -25
- data/vendor/EigenRand/LICENSE +1 -1
- data/vendor/EigenRand/README.md +109 -24
- data/vendor/tomotopy/README.kr.rst +27 -6
- data/vendor/tomotopy/README.rst +29 -8
- data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +60 -12
- data/vendor/tomotopy/src/Labeling/FoRelevance.h +2 -2
- data/vendor/tomotopy/src/Labeling/Phraser.hpp +33 -21
- data/vendor/tomotopy/src/TopicModel/CT.h +8 -5
- data/vendor/tomotopy/src/TopicModel/CTModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/CTModel.hpp +29 -23
- data/vendor/tomotopy/src/TopicModel/DMR.h +33 -4
- data/vendor/tomotopy/src/TopicModel/DMRModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +231 -57
- data/vendor/tomotopy/src/TopicModel/DT.h +24 -5
- data/vendor/tomotopy/src/TopicModel/DTModel.cpp +2 -8
- data/vendor/tomotopy/src/TopicModel/DTModel.hpp +41 -28
- data/vendor/tomotopy/src/TopicModel/GDMR.h +31 -5
- data/vendor/tomotopy/src/TopicModel/GDMRModel.cpp +2 -7
- data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +211 -104
- data/vendor/tomotopy/src/TopicModel/HDP.h +11 -2
- data/vendor/tomotopy/src/TopicModel/HDPModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +52 -45
- data/vendor/tomotopy/src/TopicModel/HLDA.h +11 -2
- data/vendor/tomotopy/src/TopicModel/HLDAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +13 -16
- data/vendor/tomotopy/src/TopicModel/HPA.h +5 -2
- data/vendor/tomotopy/src/TopicModel/HPAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +51 -21
- data/vendor/tomotopy/src/TopicModel/LDA.h +9 -2
- data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +8 -8
- data/vendor/tomotopy/src/TopicModel/LDAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +70 -28
- data/vendor/tomotopy/src/TopicModel/LLDA.h +1 -2
- data/vendor/tomotopy/src/TopicModel/LLDAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +22 -12
- data/vendor/tomotopy/src/TopicModel/MGLDA.h +12 -3
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.cpp +2 -10
- data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +42 -19
- data/vendor/tomotopy/src/TopicModel/PA.h +9 -4
- data/vendor/tomotopy/src/TopicModel/PAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/PAModel.hpp +48 -25
- data/vendor/tomotopy/src/TopicModel/PLDA.h +13 -2
- data/vendor/tomotopy/src/TopicModel/PLDAModel.cpp +2 -6
- data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +27 -19
- data/vendor/tomotopy/src/TopicModel/PT.h +12 -5
- data/vendor/tomotopy/src/TopicModel/PTModel.cpp +2 -3
- data/vendor/tomotopy/src/TopicModel/PTModel.hpp +29 -14
- data/vendor/tomotopy/src/TopicModel/SLDA.h +18 -6
- data/vendor/tomotopy/src/TopicModel/SLDAModel.cpp +2 -10
- data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +93 -43
- data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +58 -23
- data/vendor/tomotopy/src/Utils/AliasMethod.hpp +6 -6
- data/vendor/tomotopy/src/Utils/Dictionary.h +11 -0
- data/vendor/tomotopy/src/Utils/SharedString.hpp +26 -1
- data/vendor/tomotopy/src/Utils/Trie.hpp +46 -21
- data/vendor/tomotopy/src/Utils/Utils.hpp +99 -14
- data/vendor/tomotopy/src/Utils/exception.h +1 -1
- data/vendor/tomotopy/src/Utils/math.h +5 -7
- data/vendor/tomotopy/src/Utils/serializer.hpp +329 -201
- data/vendor/tomotopy/src/Utils/text.hpp +8 -0
- data/vendor/tomotopy/src/Utils/tvector.hpp +49 -7
- metadata +9 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1044b496120cf955a03d6dd184056c40572501a68043c3bd3d4cc17334caba3d
|
|
4
|
+
data.tar.gz: 7078dd4bdc562cae748ca89aa9b73d38d209d6a40a1e6d2acff0d8fba0c5a18b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef9944cc3820397ef18bbca2e42d4a1a0d4b43dd283f3fac8e066478ecc78e74b4a2d32a6f3304203e22fad048ebdacc60637b7f51a42cf6fc73053613a3e77e
|
|
7
|
+
data.tar.gz: 8409a754f890f788b6bc33938420311917418cf62f7cfde572db307a85f4473835caa342583ee6e3a6d03f517d89f75714b468351fa50011dbd156a9547c4918
|
data/CHANGELOG.md
CHANGED
data/ext/tomoto/ct.cpp
CHANGED
|
@@ -8,11 +8,15 @@ void init_ct(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::ICTModel, tomoto::ILDAModel>(m, "CT")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
12
|
+
tomoto::CTArgs args;
|
|
13
|
+
args.k = k;
|
|
14
|
+
args.alpha = {alpha};
|
|
15
|
+
args.eta = eta;
|
|
16
|
+
if (seed >= 0) {
|
|
17
|
+
args.seed = seed;
|
|
14
18
|
}
|
|
15
|
-
return tomoto::ICTModel::create((tomoto::TermWeight)tw,
|
|
19
|
+
return tomoto::ICTModel::create((tomoto::TermWeight)tw, args);
|
|
16
20
|
})
|
|
17
21
|
.define_method(
|
|
18
22
|
"_correlations",
|
data/ext/tomoto/dmr.cpp
CHANGED
|
@@ -9,11 +9,17 @@ void init_dmr(Rice::Module& m) {
|
|
|
9
9
|
Rice::define_class_under<tomoto::IDMRModel, tomoto::ILDAModel>(m, "DMR")
|
|
10
10
|
.define_singleton_method(
|
|
11
11
|
"_new",
|
|
12
|
-
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float sigma, tomoto::Float eta, tomoto::Float alpha_epsilon,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float sigma, tomoto::Float eta, tomoto::Float alpha_epsilon, size_t seed) {
|
|
13
|
+
tomoto::DMRArgs args;
|
|
14
|
+
args.k = k;
|
|
15
|
+
args.alpha = {alpha};
|
|
16
|
+
args.sigma = sigma;
|
|
17
|
+
args.eta = eta;
|
|
18
|
+
args.alphaEps = alpha_epsilon;
|
|
19
|
+
if (seed >= 0) {
|
|
20
|
+
args.seed = seed;
|
|
15
21
|
}
|
|
16
|
-
return tomoto::IDMRModel::create((tomoto::TermWeight)tw,
|
|
22
|
+
return tomoto::IDMRModel::create((tomoto::TermWeight)tw, args);
|
|
17
23
|
})
|
|
18
24
|
.define_method(
|
|
19
25
|
"_add_doc",
|
data/ext/tomoto/dt.cpp
CHANGED
|
@@ -10,11 +10,20 @@ void init_dt(Rice::Module& m) {
|
|
|
10
10
|
"_new",
|
|
11
11
|
*[](size_t tw, size_t k, size_t t, tomoto::Float alphaVar, tomoto::Float etaVar, tomoto::Float phiVar, tomoto::Float shapeA, tomoto::Float shapeB, tomoto::Float shapeC) {
|
|
12
12
|
// Rice only supports 10 arguments
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
size_t seed = -1;
|
|
14
|
+
tomoto::DTArgs args;
|
|
15
|
+
args.k = k;
|
|
16
|
+
args.t = t;
|
|
17
|
+
args.alpha = {alphaVar};
|
|
18
|
+
args.eta = etaVar;
|
|
19
|
+
args.phi = phiVar;
|
|
20
|
+
args.shapeA = shapeA;
|
|
21
|
+
args.shapeB = shapeB;
|
|
22
|
+
args.shapeC = shapeC;
|
|
23
|
+
if (seed >= 0) {
|
|
24
|
+
args.seed = seed;
|
|
16
25
|
}
|
|
17
|
-
return tomoto::IDTModel::create((tomoto::TermWeight)tw,
|
|
26
|
+
return tomoto::IDTModel::create((tomoto::TermWeight)tw, args);
|
|
18
27
|
})
|
|
19
28
|
.define_method(
|
|
20
29
|
"_add_doc",
|
data/ext/tomoto/extconf.rb
CHANGED
data/ext/tomoto/gdmr.cpp
CHANGED
|
@@ -8,17 +8,25 @@ void init_gdmr(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IGDMRModel, tomoto::IDMRModel>(m, "GDMR")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k, std::vector<uint64_t> degrees, tomoto::Float alpha, tomoto::Float sigma, tomoto::Float sigma0, tomoto::Float eta, tomoto::Float alpha_epsilon,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k, std::vector<uint64_t> degrees, tomoto::Float alpha, tomoto::Float sigma, tomoto::Float sigma0, tomoto::Float eta, tomoto::Float alpha_epsilon, size_t seed) {
|
|
12
|
+
tomoto::GDMRArgs args;
|
|
13
|
+
args.k = k;
|
|
14
|
+
args.degrees = degrees;
|
|
15
|
+
args.alpha = {alpha};
|
|
16
|
+
args.sigma = sigma;
|
|
17
|
+
args.sigma0 = sigma0;
|
|
18
|
+
args.eta = eta;
|
|
19
|
+
args.alphaEps = alpha_epsilon;
|
|
20
|
+
if (seed >= 0) {
|
|
21
|
+
args.seed = seed;
|
|
14
22
|
}
|
|
15
|
-
return tomoto::IGDMRModel::create((tomoto::TermWeight)tw,
|
|
23
|
+
return tomoto::IGDMRModel::create((tomoto::TermWeight)tw, args);
|
|
16
24
|
})
|
|
17
25
|
.define_method(
|
|
18
26
|
"_add_doc",
|
|
19
|
-
*[](tomoto::IGDMRModel& self, std::vector<std::string> words, std::vector<tomoto::Float>
|
|
27
|
+
*[](tomoto::IGDMRModel& self, std::vector<std::string> words, std::vector<tomoto::Float> numeric_metadata) {
|
|
20
28
|
auto doc = buildDoc(words);
|
|
21
|
-
doc.misc["
|
|
29
|
+
doc.misc["numeric_metadata"] = numeric_metadata;
|
|
22
30
|
return self.addDoc(doc);
|
|
23
31
|
})
|
|
24
32
|
.define_method(
|
data/ext/tomoto/hdp.cpp
CHANGED
|
@@ -8,11 +8,16 @@ void init_hdp(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IHDPModel, tomoto::ILDAModel>(m, "HDP")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma, size_t seed) {
|
|
12
|
+
tomoto::HDPArgs args;
|
|
13
|
+
args.k = k;
|
|
14
|
+
args.alpha = {alpha};
|
|
15
|
+
args.eta = eta;
|
|
16
|
+
args.gamma = gamma;
|
|
17
|
+
if (seed >= 0) {
|
|
18
|
+
args.seed = seed;
|
|
14
19
|
}
|
|
15
|
-
return tomoto::IHDPModel::create((tomoto::TermWeight)tw,
|
|
20
|
+
return tomoto::IHDPModel::create((tomoto::TermWeight)tw, args);
|
|
16
21
|
})
|
|
17
22
|
.define_method(
|
|
18
23
|
"alpha",
|
data/ext/tomoto/hlda.cpp
CHANGED
|
@@ -8,11 +8,16 @@ void init_hlda(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IHLDAModel, tomoto::ILDAModel>(m, "HLDA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t levelDepth, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t levelDepth, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma, size_t seed) {
|
|
12
|
+
tomoto::HLDAArgs args;
|
|
13
|
+
args.k = levelDepth;
|
|
14
|
+
args.alpha = {alpha};
|
|
15
|
+
args.eta = eta;
|
|
16
|
+
args.gamma = gamma;
|
|
17
|
+
if (seed >= 0) {
|
|
18
|
+
args.seed = seed;
|
|
14
19
|
}
|
|
15
|
-
return tomoto::IHLDAModel::create((tomoto::TermWeight)tw,
|
|
20
|
+
return tomoto::IHLDAModel::create((tomoto::TermWeight)tw, args);
|
|
16
21
|
})
|
|
17
22
|
.define_method(
|
|
18
23
|
"alpha",
|
data/ext/tomoto/hpa.cpp
CHANGED
|
@@ -8,11 +8,16 @@ void init_hpa(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IHPAModel, tomoto::IPAModel>(m, "HPA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k1, size_t k2, tomoto::Float alpha, tomoto::Float eta,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k1, size_t k2, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
12
|
+
tomoto::HPAArgs args;
|
|
13
|
+
args.k = k1;
|
|
14
|
+
args.k2 = k2;
|
|
15
|
+
args.alpha = {alpha};
|
|
16
|
+
args.eta = eta;
|
|
17
|
+
if (seed >= 0) {
|
|
18
|
+
args.seed = seed;
|
|
14
19
|
}
|
|
15
|
-
return tomoto::IHPAModel::create((tomoto::TermWeight)tw, false,
|
|
20
|
+
return tomoto::IHPAModel::create((tomoto::TermWeight)tw, false, args);
|
|
16
21
|
})
|
|
17
22
|
.define_method(
|
|
18
23
|
"alpha",
|
data/ext/tomoto/lda.cpp
CHANGED
|
@@ -34,11 +34,15 @@ void init_lda(Rice::Module& m) {
|
|
|
34
34
|
Rice::define_class_under<tomoto::ILDAModel>(m, "LDA")
|
|
35
35
|
.define_singleton_method(
|
|
36
36
|
"_new",
|
|
37
|
-
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta,
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
38
|
+
tomoto::LDAArgs args;
|
|
39
|
+
args.k = k;
|
|
40
|
+
args.alpha = {alpha};
|
|
41
|
+
args.eta = eta;
|
|
42
|
+
if (seed >= 0) {
|
|
43
|
+
args.seed = seed;
|
|
40
44
|
}
|
|
41
|
-
return tomoto::ILDAModel::create((tomoto::TermWeight)tw,
|
|
45
|
+
return tomoto::ILDAModel::create((tomoto::TermWeight)tw, args);
|
|
42
46
|
})
|
|
43
47
|
.define_method(
|
|
44
48
|
"_add_doc",
|
data/ext/tomoto/llda.cpp
CHANGED
|
@@ -8,11 +8,15 @@ void init_llda(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::ILLDAModel, tomoto::ILDAModel>(m, "LLDA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
12
|
+
tomoto::LDAArgs args;
|
|
13
|
+
args.k = k;
|
|
14
|
+
args.alpha = {alpha};
|
|
15
|
+
args.eta = eta;
|
|
16
|
+
if (seed >= 0) {
|
|
17
|
+
args.seed = seed;
|
|
14
18
|
}
|
|
15
|
-
return tomoto::ILLDAModel::create((tomoto::TermWeight)tw,
|
|
19
|
+
return tomoto::ILLDAModel::create((tomoto::TermWeight)tw, args);
|
|
16
20
|
})
|
|
17
21
|
.define_method(
|
|
18
22
|
"_add_doc",
|
data/ext/tomoto/mglda.cpp
CHANGED
|
@@ -9,7 +9,17 @@ void init_mglda(Rice::Module& m) {
|
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
11
|
*[](size_t tw, size_t k_g, size_t k_l, size_t t, tomoto::Float alpha_g, tomoto::Float alpha_l, tomoto::Float alpha_mg, tomoto::Float alpha_ml, tomoto::Float eta_g) {
|
|
12
|
-
|
|
12
|
+
tomoto::MGLDAArgs args;
|
|
13
|
+
args.k = k_g;
|
|
14
|
+
args.kL = k_l;
|
|
15
|
+
args.t = t;
|
|
16
|
+
args.alpha = {alpha_g};
|
|
17
|
+
args.alphaL = {alpha_l};
|
|
18
|
+
args.alphaMG = alpha_mg;
|
|
19
|
+
args.alphaML = alpha_ml;
|
|
20
|
+
args.eta = eta_g;
|
|
21
|
+
// TODO more args
|
|
22
|
+
return tomoto::IMGLDAModel::create((tomoto::TermWeight)tw, args);
|
|
13
23
|
})
|
|
14
24
|
.define_method(
|
|
15
25
|
"_add_doc",
|
data/ext/tomoto/pa.cpp
CHANGED
|
@@ -8,11 +8,16 @@ void init_pa(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IPAModel, tomoto::ILDAModel>(m, "PA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k1, size_t k2, tomoto::Float alpha, tomoto::Float eta,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t k1, size_t k2, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
12
|
+
tomoto::PAArgs args;
|
|
13
|
+
args.k = k1;
|
|
14
|
+
args.k2 = k2;
|
|
15
|
+
args.alpha = {alpha};
|
|
16
|
+
args.eta = eta;
|
|
17
|
+
if (seed >= 0) {
|
|
18
|
+
args.seed = seed;
|
|
14
19
|
}
|
|
15
|
-
return tomoto::IPAModel::create((tomoto::TermWeight)tw,
|
|
20
|
+
return tomoto::IPAModel::create((tomoto::TermWeight)tw, args);
|
|
16
21
|
})
|
|
17
22
|
.define_method(
|
|
18
23
|
"k1",
|
data/ext/tomoto/plda.cpp
CHANGED
|
@@ -8,11 +8,15 @@ void init_plda(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::IPLDAModel, tomoto::ILLDAModel>(m, "PLDA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t latent_topics, tomoto::Float alpha, tomoto::Float eta,
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*[](size_t tw, size_t latent_topics, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
|
|
12
|
+
tomoto::PLDAArgs args;
|
|
13
|
+
args.numLatentTopics = latent_topics;
|
|
14
|
+
args.alpha = {alpha};
|
|
15
|
+
args.eta = eta;
|
|
16
|
+
if (seed >= 0) {
|
|
17
|
+
args.seed = seed;
|
|
14
18
|
}
|
|
15
|
-
return tomoto::IPLDAModel::create((tomoto::TermWeight)tw,
|
|
19
|
+
return tomoto::IPLDAModel::create((tomoto::TermWeight)tw, args);
|
|
16
20
|
})
|
|
17
21
|
.define_method(
|
|
18
22
|
"_add_doc",
|
data/ext/tomoto/slda.cpp
CHANGED
|
@@ -8,16 +8,24 @@ void init_slda(Rice::Module& m) {
|
|
|
8
8
|
Rice::define_class_under<tomoto::ISLDAModel, tomoto::ILDAModel>(m, "SLDA")
|
|
9
9
|
.define_singleton_method(
|
|
10
10
|
"_new",
|
|
11
|
-
*[](size_t tw, size_t k, Array rb_vars, tomoto::Float alpha, tomoto::Float eta, std::vector<tomoto::Float> mu, std::vector<tomoto::Float> nu_sq, std::vector<tomoto::Float> glm_param,
|
|
12
|
-
if (seed < 0) {
|
|
13
|
-
seed = std::random_device{}();
|
|
14
|
-
}
|
|
11
|
+
*[](size_t tw, size_t k, Array rb_vars, tomoto::Float alpha, tomoto::Float eta, std::vector<tomoto::Float> mu, std::vector<tomoto::Float> nu_sq, std::vector<tomoto::Float> glm_param, size_t seed) {
|
|
15
12
|
std::vector<tomoto::ISLDAModel::GLM> vars;
|
|
16
13
|
vars.reserve(rb_vars.size());
|
|
17
14
|
for (auto const& v : rb_vars) {
|
|
18
15
|
vars.push_back((tomoto::ISLDAModel::GLM) from_ruby<int>(v));
|
|
19
16
|
}
|
|
20
|
-
|
|
17
|
+
tomoto::SLDAArgs args;
|
|
18
|
+
args.k = k;
|
|
19
|
+
args.vars = vars;
|
|
20
|
+
args.alpha = {alpha};
|
|
21
|
+
args.eta = eta;
|
|
22
|
+
args.mu = mu;
|
|
23
|
+
args.nuSq = nu_sq;
|
|
24
|
+
args.glmParam = glm_param;
|
|
25
|
+
if (seed >= 0) {
|
|
26
|
+
args.seed = seed;
|
|
27
|
+
}
|
|
28
|
+
return tomoto::ISLDAModel::create((tomoto::TermWeight)tw, args);
|
|
21
29
|
})
|
|
22
30
|
.define_method(
|
|
23
31
|
"_add_doc",
|
data/lib/tomoto/gdmr.rb
CHANGED
data/lib/tomoto/version.rb
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @file Core.h
|
|
3
3
|
* @author bab2min (bab2min@gmail.com)
|
|
4
4
|
* @brief
|
|
5
|
-
* @version 0.
|
|
6
|
-
* @date 2020-
|
|
5
|
+
* @version 0.3.0
|
|
6
|
+
* @date 2020-10-07
|
|
7
7
|
*
|
|
8
8
|
* @copyright Copyright (c) 2020
|
|
9
9
|
*
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
#define EIGENRAND_CORE_H
|
|
15
15
|
|
|
16
16
|
#include <EigenRand/RandUtils.h>
|
|
17
|
+
|
|
17
18
|
#include <EigenRand/Dists/Basic.h>
|
|
18
19
|
#include <EigenRand/Dists/Discrete.h>
|
|
19
20
|
#include <EigenRand/Dists/NormalExp.h>
|
|
20
21
|
#include <EigenRand/Dists/GammaPoisson.h>
|
|
21
22
|
|
|
23
|
+
#include <EigenRand/MvDists/MvNormal.h>
|
|
24
|
+
#include <EigenRand/MvDists/Multinomial.h>
|
|
25
|
+
|
|
22
26
|
namespace Eigen
|
|
23
27
|
{
|
|
24
28
|
/**
|
|
@@ -27,1112 +31,7 @@ namespace Eigen
|
|
|
27
31
|
*/
|
|
28
32
|
namespace Rand
|
|
29
33
|
{
|
|
30
|
-
template<typename Derived, typename Urng>
|
|
31
|
-
using RandBitsType = CwiseNullaryOp<internal::scalar_randbits_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @brief generates integers with random bits
|
|
35
|
-
*
|
|
36
|
-
* @tparam Derived
|
|
37
|
-
* @tparam Urng
|
|
38
|
-
* @param rows the number of rows being generated
|
|
39
|
-
* @param cols the number of columns being generated
|
|
40
|
-
* @param urng c++11-style random number generator
|
|
41
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
42
|
-
*/
|
|
43
|
-
template<typename Derived, typename Urng>
|
|
44
|
-
inline const RandBitsType<Derived, Urng>
|
|
45
|
-
randBits(Index rows, Index cols, Urng&& urng)
|
|
46
|
-
{
|
|
47
|
-
return {
|
|
48
|
-
rows, cols, internal::scalar_randbits_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @brief generates integers with random bits
|
|
54
|
-
*
|
|
55
|
-
* @tparam Derived
|
|
56
|
-
* @tparam Urng
|
|
57
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
58
|
-
* @param urng c++11-style random number generator
|
|
59
|
-
* @return a random matrix expression of the same shape as `o`
|
|
60
|
-
*/
|
|
61
|
-
template<typename Derived, typename Urng>
|
|
62
|
-
inline const RandBitsType<Derived, Urng>
|
|
63
|
-
randBitsLike(Derived& o, Urng&& urng)
|
|
64
|
-
{
|
|
65
|
-
return {
|
|
66
|
-
o.rows(), o.cols(), internal::scalar_randbits_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
template<typename Derived, typename Urng>
|
|
71
|
-
using UniformIntType = CwiseNullaryOp<internal::scalar_uniform_int_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @brief generates integers with a given range `[min, max]`
|
|
75
|
-
*
|
|
76
|
-
* @tparam Derived a type of Eigen::DenseBase
|
|
77
|
-
* @tparam Urng
|
|
78
|
-
* @param rows the number of rows being generated
|
|
79
|
-
* @param cols the number of columns being generated
|
|
80
|
-
* @param urng c++11-style random number generator
|
|
81
|
-
* @param min, max the range of integers being generated
|
|
82
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
83
|
-
*/
|
|
84
|
-
template<typename Derived, typename Urng>
|
|
85
|
-
inline const UniformIntType<Derived, Urng>
|
|
86
|
-
uniformInt(Index rows, Index cols, Urng&& urng, typename Derived::Scalar min, typename Derived::Scalar max)
|
|
87
|
-
{
|
|
88
|
-
return {
|
|
89
|
-
rows, cols, internal::scalar_uniform_int_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), min, max)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @brief generates integers with a given range `[min, max]`
|
|
95
|
-
*
|
|
96
|
-
* @tparam Derived
|
|
97
|
-
* @tparam Urng
|
|
98
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
99
|
-
* @param urng c++11-style random number generator
|
|
100
|
-
* @param min, max the range of integers being generated
|
|
101
|
-
* @return a random matrix expression of the same shape as `o`
|
|
102
|
-
*/
|
|
103
|
-
template<typename Derived, typename Urng>
|
|
104
|
-
inline const UniformIntType<Derived, Urng>
|
|
105
|
-
uniformIntLike(Derived& o, Urng&& urng, typename Derived::Scalar min, typename Derived::Scalar max)
|
|
106
|
-
{
|
|
107
|
-
return {
|
|
108
|
-
o.rows(), o.cols(), internal::scalar_uniform_int_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), min, max)
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
template<typename Derived, typename Urng>
|
|
113
|
-
using BalancedType = CwiseNullaryOp<internal::scalar_balanced_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @brief generates reals in a range `[-1, 1]`
|
|
117
|
-
*
|
|
118
|
-
* @tparam Derived a type of Eigen::DenseBase
|
|
119
|
-
* @tparam Urng
|
|
120
|
-
* @param rows the number of rows being generated
|
|
121
|
-
* @param cols the number of columns being generated
|
|
122
|
-
* @param urng c++11-style random number generator
|
|
123
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
124
|
-
*/
|
|
125
|
-
template<typename Derived, typename Urng>
|
|
126
|
-
inline const BalancedType<Derived, Urng>
|
|
127
|
-
balanced(Index rows, Index cols, Urng&& urng)
|
|
128
|
-
{
|
|
129
|
-
return {
|
|
130
|
-
rows, cols, internal::scalar_balanced_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @brief generates reals in a range `[-1, 1]`
|
|
136
|
-
*
|
|
137
|
-
* @tparam Derived
|
|
138
|
-
* @tparam Urng
|
|
139
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
140
|
-
* @param urng c++11-style random number generator
|
|
141
|
-
* @return a random matrix expression of the same shape as `o`
|
|
142
|
-
*/
|
|
143
|
-
template<typename Derived, typename Urng>
|
|
144
|
-
inline const BalancedType<Derived, Urng>
|
|
145
|
-
balancedLike(const Derived& o, Urng&& urng)
|
|
146
|
-
{
|
|
147
|
-
return {
|
|
148
|
-
o.rows(), o.cols(), internal::scalar_balanced_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
template<typename Derived, typename Urng>
|
|
153
|
-
using UniformRealType = CwiseNullaryOp<internal::scalar_uniform_real_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @brief generates reals in a range `[0, 1)`
|
|
157
|
-
*
|
|
158
|
-
* @tparam Derived a type of Eigen::DenseBase
|
|
159
|
-
* @tparam Urng
|
|
160
|
-
* @param rows the number of rows being generated
|
|
161
|
-
* @param cols the number of columns being generated
|
|
162
|
-
* @param urng c++11-style random number generator
|
|
163
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
164
|
-
*/
|
|
165
|
-
template<typename Derived, typename Urng>
|
|
166
|
-
inline const UniformRealType<Derived, Urng>
|
|
167
|
-
uniformReal(Index rows, Index cols, Urng&& urng)
|
|
168
|
-
{
|
|
169
|
-
return {
|
|
170
|
-
rows, cols, internal::scalar_uniform_real_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @brief generates reals in a range `[0, 1)`
|
|
176
|
-
*
|
|
177
|
-
* @tparam Derived
|
|
178
|
-
* @tparam Urng
|
|
179
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
180
|
-
* @param urng c++11-style random number generator
|
|
181
|
-
* @return a random matrix expression of the same shape as `o`
|
|
182
|
-
*/
|
|
183
|
-
template<typename Derived, typename Urng>
|
|
184
|
-
inline const UniformRealType<Derived, Urng>
|
|
185
|
-
uniformRealLike(Derived& o, Urng&& urng)
|
|
186
|
-
{
|
|
187
|
-
return {
|
|
188
|
-
o.rows(), o.cols(), internal::scalar_uniform_real_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
template<typename Derived, typename Urng>
|
|
193
|
-
using NormalType = CwiseNullaryOp<internal::scalar_norm_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @brief generates reals on a standard normal distribution (`mean` = 0, `stdev`=1)
|
|
197
|
-
*
|
|
198
|
-
* @tparam Derived a type of Eigen::DenseBase
|
|
199
|
-
* @tparam Urng
|
|
200
|
-
* @param rows the number of rows being generated
|
|
201
|
-
* @param cols the number of columns being generated
|
|
202
|
-
* @param urng c++11-style random number generator
|
|
203
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
204
|
-
*/
|
|
205
|
-
template<typename Derived, typename Urng>
|
|
206
|
-
inline const NormalType<Derived, Urng>
|
|
207
|
-
normal(Index rows, Index cols, Urng&& urng)
|
|
208
|
-
{
|
|
209
|
-
return {
|
|
210
|
-
rows, cols, internal::scalar_norm_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @brief generates reals on a standard normal distribution (`mean` = 0, `stdev`=1)
|
|
216
|
-
*
|
|
217
|
-
* @tparam Derived
|
|
218
|
-
* @tparam Urng
|
|
219
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
220
|
-
* @param urng c++11-style random number generator
|
|
221
|
-
* @return a random matrix expression of the same shape as `o`
|
|
222
|
-
*/
|
|
223
|
-
template<typename Derived, typename Urng>
|
|
224
|
-
inline const NormalType<Derived, Urng>
|
|
225
|
-
normalLike(Derived& o, Urng&& urng)
|
|
226
|
-
{
|
|
227
|
-
return {
|
|
228
|
-
o.rows(), o.cols(), internal::scalar_norm_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng))
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
template<typename Derived, typename Urng>
|
|
233
|
-
using Normal2Type = CwiseNullaryOp<internal::scalar_norm_dist2_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* @brief generates reals on a normal distribution with arbitrary `mean` and `stdev`.
|
|
237
|
-
*
|
|
238
|
-
* @tparam Derived
|
|
239
|
-
* @tparam Urng
|
|
240
|
-
* @param rows the number of rows being generated
|
|
241
|
-
* @param cols the number of columns being generated
|
|
242
|
-
* @param urng c++11-style random number generator
|
|
243
|
-
* @param mean a mean value of the distribution
|
|
244
|
-
* @param stdev a standard deviation value of the distribution
|
|
245
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
246
|
-
*/
|
|
247
|
-
template<typename Derived, typename Urng>
|
|
248
|
-
inline const Normal2Type<Derived, Urng>
|
|
249
|
-
normal(Index rows, Index cols, Urng&& urng, typename Derived::Scalar mean, typename Derived::Scalar stdev = 1)
|
|
250
|
-
{
|
|
251
|
-
return {
|
|
252
|
-
rows, cols, internal::scalar_norm_dist2_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean, stdev)
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* @brief generates reals on a normal distribution with arbitrary `mean` and `stdev`.
|
|
258
|
-
*
|
|
259
|
-
* @tparam Derived
|
|
260
|
-
* @tparam Urng
|
|
261
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
262
|
-
* @param urng c++11-style random number generator
|
|
263
|
-
* @param mean a mean value of the distribution
|
|
264
|
-
* @param stdev a standard deviation value of the distribution
|
|
265
|
-
* @return a random matrix expression of the same shape as `o`
|
|
266
|
-
*/
|
|
267
|
-
template<typename Derived, typename Urng>
|
|
268
|
-
inline const Normal2Type<Derived, Urng>
|
|
269
|
-
normalLike(Derived& o, Urng&& urng, typename Derived::Scalar mean, typename Derived::Scalar stdev = 1)
|
|
270
|
-
{
|
|
271
|
-
return {
|
|
272
|
-
o.rows(), o.cols(), internal::scalar_norm_dist2_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean, stdev)
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
template<typename Derived, typename Urng>
|
|
277
|
-
using LognormalType = CwiseNullaryOp<internal::scalar_lognorm_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* @brief generates reals on a lognormal distribution with arbitrary `mean` and `stdev`.
|
|
281
|
-
*
|
|
282
|
-
* @tparam Derived
|
|
283
|
-
* @tparam Urng
|
|
284
|
-
* @param rows the number of rows being generated
|
|
285
|
-
* @param cols the number of columns being generated
|
|
286
|
-
* @param urng c++11-style random number generator
|
|
287
|
-
* @param mean a mean value of the distribution
|
|
288
|
-
* @param stdev a standard deviation value of the distribution
|
|
289
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
290
|
-
*/
|
|
291
|
-
template<typename Derived, typename Urng>
|
|
292
|
-
inline const LognormalType<Derived, Urng>
|
|
293
|
-
lognormal(Index rows, Index cols, Urng&& urng, typename Derived::Scalar mean = 0, typename Derived::Scalar stdev = 1)
|
|
294
|
-
{
|
|
295
|
-
return {
|
|
296
|
-
rows, cols, internal::scalar_lognorm_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean, stdev)
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @brief generates reals on a lognormal distribution with arbitrary `mean` and `stdev`.
|
|
302
|
-
*
|
|
303
|
-
* @tparam Derived
|
|
304
|
-
* @tparam Urng
|
|
305
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
306
|
-
* @param urng c++11-style random number generator
|
|
307
|
-
* @param mean a mean value of the distribution
|
|
308
|
-
* @param stdev a standard deviation value of the distribution
|
|
309
|
-
* @return a random matrix expression of the same shape as `o`
|
|
310
|
-
*/
|
|
311
|
-
template<typename Derived, typename Urng>
|
|
312
|
-
inline const LognormalType<Derived, Urng>
|
|
313
|
-
lognormalLike(Derived& o, Urng&& urng, typename Derived::Scalar mean = 0, typename Derived::Scalar stdev = 1)
|
|
314
|
-
{
|
|
315
|
-
return {
|
|
316
|
-
o.rows(), o.cols(), internal::scalar_lognorm_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean, stdev)
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
template<typename Derived, typename Urng>
|
|
321
|
-
using StudentTType = CwiseNullaryOp<internal::scalar_student_t_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* @brief generates reals on the Student's t distribution with arbirtrary degress of freedom.
|
|
325
|
-
*
|
|
326
|
-
* @tparam Derived a type of Eigen::DenseBase
|
|
327
|
-
* @tparam Urng
|
|
328
|
-
* @param rows the number of rows being generated
|
|
329
|
-
* @param cols the number of columns being generated
|
|
330
|
-
* @param urng c++11-style random number generator
|
|
331
|
-
* @param n degrees of freedom
|
|
332
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
333
|
-
*/
|
|
334
|
-
template<typename Derived, typename Urng>
|
|
335
|
-
inline const StudentTType<Derived, Urng>
|
|
336
|
-
studentT(Index rows, Index cols, Urng&& urng, typename Derived::Scalar n = 1)
|
|
337
|
-
{
|
|
338
|
-
return {
|
|
339
|
-
rows, cols, internal::scalar_student_t_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), n)
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @brief generates reals on the Student's t distribution with arbirtrary degress of freedom.
|
|
345
|
-
*
|
|
346
|
-
* @tparam Derived
|
|
347
|
-
* @tparam Urng
|
|
348
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
349
|
-
* @param urng c++11-style random number generator
|
|
350
|
-
* @param n degrees of freedom
|
|
351
|
-
* @return a random matrix expression of the same shape as `o`
|
|
352
|
-
*/
|
|
353
|
-
template<typename Derived, typename Urng>
|
|
354
|
-
inline const StudentTType<Derived, Urng>
|
|
355
|
-
studentTLike(Derived& o, Urng&& urng, typename Derived::Scalar n = 1)
|
|
356
|
-
{
|
|
357
|
-
return {
|
|
358
|
-
o.rows(), o.cols(), internal::scalar_student_t_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), n)
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
template<typename Derived, typename Urng>
|
|
363
|
-
using ExponentialType = CwiseNullaryOp<internal::scalar_exp_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @brief generates reals on an exponential distribution with arbitrary scale parameter.
|
|
367
|
-
*
|
|
368
|
-
* @tparam Derived
|
|
369
|
-
* @tparam Urng
|
|
370
|
-
* @param rows the number of rows being generated
|
|
371
|
-
* @param cols the number of columns being generated
|
|
372
|
-
* @param urng c++11-style random number generator
|
|
373
|
-
* @param lambda a scale parameter of the distribution
|
|
374
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
375
|
-
*/
|
|
376
|
-
template<typename Derived, typename Urng>
|
|
377
|
-
inline const ExponentialType<Derived, Urng>
|
|
378
|
-
exponential(Index rows, Index cols, Urng&& urng, typename Derived::Scalar lambda = 1)
|
|
379
|
-
{
|
|
380
|
-
return {
|
|
381
|
-
rows, cols, internal::scalar_exp_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), lambda)
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* @brief generates reals on an exponential distribution with arbitrary scale parameter.
|
|
387
|
-
*
|
|
388
|
-
* @tparam Derived
|
|
389
|
-
* @tparam Urng
|
|
390
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
391
|
-
* @param urng c++11-style random number generator
|
|
392
|
-
* @param lambda a scale parameter of the distribution
|
|
393
|
-
* @return a random matrix expression of the same shape as `o`
|
|
394
|
-
*/
|
|
395
|
-
template<typename Derived, typename Urng>
|
|
396
|
-
inline const ExponentialType<Derived, Urng>
|
|
397
|
-
exponentialLike(Derived& o, Urng&& urng, typename Derived::Scalar lambda = 1)
|
|
398
|
-
{
|
|
399
|
-
return {
|
|
400
|
-
o.rows(), o.cols(), internal::scalar_exp_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), lambda)
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
template<typename Derived, typename Urng>
|
|
405
|
-
using GammaType = CwiseNullaryOp<internal::scalar_gamma_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* @brief generates reals on a gamma distribution with arbitrary shape and scale parameter.
|
|
409
|
-
*
|
|
410
|
-
* @tparam Derived
|
|
411
|
-
* @tparam Urng
|
|
412
|
-
* @param rows the number of rows being generated
|
|
413
|
-
* @param cols the number of columns being generated
|
|
414
|
-
* @param urng c++11-style random number generator
|
|
415
|
-
* @param alpha a shape parameter of the distribution
|
|
416
|
-
* @param beta a scale parameter of the distribution
|
|
417
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
418
|
-
*/
|
|
419
|
-
template<typename Derived, typename Urng>
|
|
420
|
-
inline const GammaType<Derived, Urng>
|
|
421
|
-
gamma(Index rows, Index cols, Urng&& urng, typename Derived::Scalar alpha = 1, typename Derived::Scalar beta = 1)
|
|
422
|
-
{
|
|
423
|
-
return {
|
|
424
|
-
rows, cols, internal::scalar_gamma_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), alpha, beta)
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* @brief generates reals on a gamma distribution with arbitrary shape and scale parameter.
|
|
430
|
-
*
|
|
431
|
-
* @tparam Derived
|
|
432
|
-
* @tparam Urng
|
|
433
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
434
|
-
* @param urng c++11-style random number generator
|
|
435
|
-
* @param alpha a shape parameter of the distribution
|
|
436
|
-
* @param beta a scale parameter of the distribution
|
|
437
|
-
* @return a random matrix expression of the same shape as `o`
|
|
438
|
-
*/
|
|
439
|
-
template<typename Derived, typename Urng>
|
|
440
|
-
inline const GammaType<Derived, Urng>
|
|
441
|
-
gammaLike(Derived& o, Urng&& urng, typename Derived::Scalar alpha = 1, typename Derived::Scalar beta = 1)
|
|
442
|
-
{
|
|
443
|
-
return {
|
|
444
|
-
o.rows(), o.cols(), internal::scalar_gamma_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), alpha, beta)
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
template<typename Derived, typename Urng>
|
|
449
|
-
using WeibullType = CwiseNullaryOp<internal::scalar_weibull_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* @brief generates reals on a Weibull distribution with arbitrary shape and scale parameter.
|
|
453
|
-
*
|
|
454
|
-
* @tparam Derived
|
|
455
|
-
* @tparam Urng
|
|
456
|
-
* @param rows the number of rows being generated
|
|
457
|
-
* @param cols the number of columns being generated
|
|
458
|
-
* @param urng c++11-style random number generator
|
|
459
|
-
* @param a a shape parameter of the distribution
|
|
460
|
-
* @param b a scale parameter of the distribution
|
|
461
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
462
|
-
*/
|
|
463
|
-
template<typename Derived, typename Urng>
|
|
464
|
-
inline const WeibullType<Derived, Urng>
|
|
465
|
-
weibull(Index rows, Index cols, Urng&& urng, typename Derived::Scalar a = 1, typename Derived::Scalar b = 1)
|
|
466
|
-
{
|
|
467
|
-
return {
|
|
468
|
-
rows, cols, internal::scalar_weibull_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* @brief generates reals on a Weibull distribution with arbitrary shape and scale parameter.
|
|
474
|
-
*
|
|
475
|
-
* @tparam Derived
|
|
476
|
-
* @tparam Urng
|
|
477
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
478
|
-
* @param urng c++11-style random number generator
|
|
479
|
-
* @param a a shape parameter of the distribution
|
|
480
|
-
* @param b a scale parameter of the distribution
|
|
481
|
-
* @return a random matrix expression of the same shape as `o`
|
|
482
|
-
*/
|
|
483
|
-
template<typename Derived, typename Urng>
|
|
484
|
-
inline const WeibullType<Derived, Urng>
|
|
485
|
-
weibullLike(Derived& o, Urng&& urng, typename Derived::Scalar a = 1, typename Derived::Scalar b = 1)
|
|
486
|
-
{
|
|
487
|
-
return {
|
|
488
|
-
o.rows(), o.cols(), internal::scalar_weibull_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
template<typename Derived, typename Urng>
|
|
493
|
-
using ExtremeValueType = CwiseNullaryOp<internal::scalar_extreme_value_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* @brief generates reals on an extreme value distribution
|
|
497
|
-
* (a.k.a Gumbel Type I, log-Weibull, Fisher-Tippett Type I) with arbitrary shape and scale parameter.
|
|
498
|
-
*
|
|
499
|
-
* @tparam Derived
|
|
500
|
-
* @tparam Urng
|
|
501
|
-
* @param rows the number of rows being generated
|
|
502
|
-
* @param cols the number of columns being generated
|
|
503
|
-
* @param urng c++11-style random number generator
|
|
504
|
-
* @param a a location parameter of the distribution
|
|
505
|
-
* @param b a scale parameter of the distribution
|
|
506
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
507
|
-
*/
|
|
508
|
-
template<typename Derived, typename Urng>
|
|
509
|
-
inline const ExtremeValueType<Derived, Urng>
|
|
510
|
-
extremeValue(Index rows, Index cols, Urng&& urng, typename Derived::Scalar a = 0, typename Derived::Scalar b = 1)
|
|
511
|
-
{
|
|
512
|
-
return {
|
|
513
|
-
rows, cols, internal::scalar_extreme_value_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* @brief generates reals on an extreme value distribution
|
|
519
|
-
* (a.k.a Gumbel Type I, log-Weibull, Fisher-Tippett Type I) with arbitrary shape and scale parameter.
|
|
520
|
-
*
|
|
521
|
-
* @tparam Derived
|
|
522
|
-
* @tparam Urng
|
|
523
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
524
|
-
* @param urng c++11-style random number generator
|
|
525
|
-
* @param a a location parameter of the distribution
|
|
526
|
-
* @param b a scale parameter of the distribution
|
|
527
|
-
* @return a random matrix expression of the same shape as `o`
|
|
528
|
-
*/
|
|
529
|
-
template<typename Derived, typename Urng>
|
|
530
|
-
inline const ExtremeValueType<Derived, Urng>
|
|
531
|
-
extremeValueLike(Derived& o, Urng&& urng, typename Derived::Scalar a = 0, typename Derived::Scalar b = 1)
|
|
532
|
-
{
|
|
533
|
-
return {
|
|
534
|
-
o.rows(), o.cols(), internal::scalar_extreme_value_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
template<typename Derived, typename Urng>
|
|
539
|
-
using ChiSquaredType = CwiseNullaryOp<internal::scalar_chi_squared_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* @brief generates reals on the Chi-squared distribution with arbitrary degrees of freedom.
|
|
543
|
-
*
|
|
544
|
-
* @tparam Derived
|
|
545
|
-
* @tparam Urng
|
|
546
|
-
* @param rows the number of rows being generated
|
|
547
|
-
* @param cols the number of columns being generated
|
|
548
|
-
* @param urng c++11-style random number generator
|
|
549
|
-
* @param n the degrees of freedom of the distribution
|
|
550
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
551
|
-
*/
|
|
552
|
-
template<typename Derived, typename Urng>
|
|
553
|
-
inline const ChiSquaredType<Derived, Urng>
|
|
554
|
-
chiSquared(Index rows, Index cols, Urng&& urng, typename Derived::Scalar n = 1)
|
|
555
|
-
{
|
|
556
|
-
return {
|
|
557
|
-
rows, cols, internal::scalar_chi_squared_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), n)
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* @brief generates reals on the Chi-squared distribution with arbitrary degrees of freedom.
|
|
563
|
-
*
|
|
564
|
-
* @tparam Derived
|
|
565
|
-
* @tparam Urng
|
|
566
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
567
|
-
* @param urng c++11-style random number generator
|
|
568
|
-
* @param n the degrees of freedom of the distribution
|
|
569
|
-
* @return a random matrix expression of the same shape as `o`
|
|
570
|
-
*/
|
|
571
|
-
template<typename Derived, typename Urng>
|
|
572
|
-
inline const ChiSquaredType<Derived, Urng>
|
|
573
|
-
chiSquaredLike(Derived& o, Urng&& urng, typename Derived::Scalar n = 1)
|
|
574
|
-
{
|
|
575
|
-
return {
|
|
576
|
-
o.rows(), o.cols(), internal::scalar_chi_squared_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), n)
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
template<typename Derived, typename Urng>
|
|
581
|
-
using CauchyType = CwiseNullaryOp<internal::scalar_cauchy_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* @brief generates reals on the Cauchy distribution.
|
|
585
|
-
*
|
|
586
|
-
* @tparam Derived
|
|
587
|
-
* @tparam Urng
|
|
588
|
-
* @param rows the number of rows being generated
|
|
589
|
-
* @param cols the number of columns being generated
|
|
590
|
-
* @param urng c++11-style random number generator
|
|
591
|
-
* @param a a location parameter of the distribution
|
|
592
|
-
* @param b a scale parameter of the distribution
|
|
593
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
594
|
-
*/
|
|
595
|
-
template<typename Derived, typename Urng>
|
|
596
|
-
inline const CauchyType<Derived, Urng>
|
|
597
|
-
cauchy(Index rows, Index cols, Urng&& urng, typename Derived::Scalar a = 0, typename Derived::Scalar b = 1)
|
|
598
|
-
{
|
|
599
|
-
return {
|
|
600
|
-
rows, cols, internal::scalar_cauchy_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* @brief generates reals on the Cauchy distribution.
|
|
606
|
-
*
|
|
607
|
-
* @tparam Derived
|
|
608
|
-
* @tparam Urng
|
|
609
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
610
|
-
* @param urng c++11-style random number generator
|
|
611
|
-
* @param a a location parameter of the distribution
|
|
612
|
-
* @param b a scale parameter of the distribution
|
|
613
|
-
* @return a random matrix expression of the same shape as `o`
|
|
614
|
-
*/
|
|
615
|
-
template<typename Derived, typename Urng>
|
|
616
|
-
inline const CauchyType<Derived, Urng>
|
|
617
|
-
cauchyLike(Derived& o, Urng&& urng, typename Derived::Scalar a = 0, typename Derived::Scalar b = 1)
|
|
618
|
-
{
|
|
619
|
-
return {
|
|
620
|
-
o.rows(), o.cols(), internal::scalar_cauchy_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
template<typename Derived, typename Urng>
|
|
625
|
-
using FisherFType = CwiseNullaryOp<internal::scalar_fisher_f_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* @brief generates reals on the Fisher's F distribution.
|
|
629
|
-
*
|
|
630
|
-
* @tparam Derived
|
|
631
|
-
* @tparam Urng
|
|
632
|
-
* @param rows the number of rows being generated
|
|
633
|
-
* @param cols the number of columns being generated
|
|
634
|
-
* @param urng c++11-style random number generator
|
|
635
|
-
* @param m degrees of freedom
|
|
636
|
-
* @param n degrees of freedom
|
|
637
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
638
|
-
*/
|
|
639
|
-
template<typename Derived, typename Urng>
|
|
640
|
-
inline const FisherFType<Derived, Urng>
|
|
641
|
-
fisherF(Index rows, Index cols, Urng&& urng, typename Derived::Scalar m = 1, typename Derived::Scalar n = 1)
|
|
642
|
-
{
|
|
643
|
-
return {
|
|
644
|
-
rows, cols, internal::scalar_fisher_f_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), m, n)
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* @brief generates reals on the Fisher's F distribution.
|
|
650
|
-
*
|
|
651
|
-
* @tparam Derived
|
|
652
|
-
* @tparam Urng
|
|
653
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
654
|
-
* @param urng c++11-style random number generator
|
|
655
|
-
* @param m degrees of freedom
|
|
656
|
-
* @param n degrees of freedom
|
|
657
|
-
* @return a random matrix expression of the same shape as `o`
|
|
658
|
-
*/
|
|
659
|
-
template<typename Derived, typename Urng>
|
|
660
|
-
inline const FisherFType<Derived, Urng>
|
|
661
|
-
fisherFLike(Derived& o, Urng&& urng, typename Derived::Scalar m = 1, typename Derived::Scalar n = 1)
|
|
662
|
-
{
|
|
663
|
-
return {
|
|
664
|
-
o.rows(), o.cols(), internal::scalar_fisher_f_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), m, n)
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
template<typename Derived, typename Urng>
|
|
669
|
-
using BetaType = CwiseNullaryOp<internal::scalar_beta_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* @brief generates reals on the beta distribution.
|
|
673
|
-
*
|
|
674
|
-
* @tparam Derived
|
|
675
|
-
* @tparam Urng
|
|
676
|
-
* @param rows the number of rows being generated
|
|
677
|
-
* @param cols the number of columns being generated
|
|
678
|
-
* @param urng c++11-style random number generator
|
|
679
|
-
* @param a,b shape parameter
|
|
680
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
681
|
-
*/
|
|
682
|
-
template<typename Derived, typename Urng>
|
|
683
|
-
inline const BetaType<Derived, Urng>
|
|
684
|
-
beta(Index rows, Index cols, Urng&& urng, typename Derived::Scalar a = 1, typename Derived::Scalar b = 1)
|
|
685
|
-
{
|
|
686
|
-
return {
|
|
687
|
-
rows, cols, internal::scalar_beta_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* @brief generates reals on the beta distribution.
|
|
693
|
-
*
|
|
694
|
-
* @tparam Derived
|
|
695
|
-
* @tparam Urng
|
|
696
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
697
|
-
* @param urng c++11-style random number generator
|
|
698
|
-
* @param a,b shape parameter
|
|
699
|
-
* @return a random matrix expression of the same shape as `o`
|
|
700
|
-
*/
|
|
701
|
-
template<typename Derived, typename Urng>
|
|
702
|
-
inline const BetaType<Derived, Urng>
|
|
703
|
-
betaLike(Derived& o, Urng&& urng, typename Derived::Scalar a = 1, typename Derived::Scalar b = 1)
|
|
704
|
-
{
|
|
705
|
-
return {
|
|
706
|
-
o.rows(), o.cols(), internal::scalar_beta_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), a, b)
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
template<typename Derived, typename Urng>
|
|
711
|
-
using DiscreteFType = CwiseNullaryOp<internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, float>, const Derived>;
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
715
|
-
* The data type used for calculation of probabilities is float(23bit precision).
|
|
716
|
-
*
|
|
717
|
-
* @tparam Derived
|
|
718
|
-
* @tparam Urng
|
|
719
|
-
* @param rows the number of rows being generated
|
|
720
|
-
* @param cols the number of columns being generated
|
|
721
|
-
* @param urng c++11-style random number generator
|
|
722
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
723
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
724
|
-
*/
|
|
725
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
726
|
-
inline const DiscreteFType<Derived, Urng>
|
|
727
|
-
discreteF(Index rows, Index cols, Urng&& urng, RealIter first, RealIter last)
|
|
728
|
-
{
|
|
729
|
-
return {
|
|
730
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), first, last)
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
736
|
-
* The data type used for calculation of probabilities is float(23bit precision).
|
|
737
|
-
*
|
|
738
|
-
* @tparam Derived
|
|
739
|
-
* @tparam Urng
|
|
740
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
741
|
-
* @param urng c++11-style random number generator
|
|
742
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
743
|
-
* @return a random matrix expression of the same shape as `o`
|
|
744
|
-
*/
|
|
745
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
746
|
-
inline const DiscreteFType<Derived, Urng>
|
|
747
|
-
discreteFLike(Derived& o, Urng&& urng, RealIter first, RealIter last)
|
|
748
|
-
{
|
|
749
|
-
return {
|
|
750
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), first, last)
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
756
|
-
* The data type used for calculation of probabilities is float(23bit precision).
|
|
757
|
-
*
|
|
758
|
-
* @tparam Derived
|
|
759
|
-
* @tparam Urng
|
|
760
|
-
* @param rows the number of rows being generated
|
|
761
|
-
* @param cols the number of columns being generated
|
|
762
|
-
* @param urng c++11-style random number generator
|
|
763
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
764
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
765
|
-
*/
|
|
766
|
-
template<typename Derived, typename Urng, typename Real>
|
|
767
|
-
inline const DiscreteFType<Derived, Urng>
|
|
768
|
-
discreteF(Index rows, Index cols, Urng&& urng, const std::initializer_list<Real>& il)
|
|
769
|
-
{
|
|
770
|
-
return {
|
|
771
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
777
|
-
* The data type used for calculation of probabilities is float(23bit precision).
|
|
778
|
-
*
|
|
779
|
-
* @tparam Derived
|
|
780
|
-
* @tparam Urng
|
|
781
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
782
|
-
* @param urng c++11-style random number generator
|
|
783
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
784
|
-
* @return a random matrix expression of the same shape as `o`
|
|
785
|
-
*/
|
|
786
|
-
template<typename Derived, typename Urng, typename Real>
|
|
787
|
-
inline const DiscreteFType<Derived, Urng>
|
|
788
|
-
discreteFLike(Derived& o, Urng&& urng, const std::initializer_list<Real>& il)
|
|
789
|
-
{
|
|
790
|
-
return {
|
|
791
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
template<typename Derived, typename Urng>
|
|
796
|
-
using DiscreteDType = CwiseNullaryOp<internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, double>, const Derived>;
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
800
|
-
* The data type used for calculation of probabilities is double(52bit precision).
|
|
801
|
-
*
|
|
802
|
-
* @tparam Derived
|
|
803
|
-
* @tparam Urng
|
|
804
|
-
* @param rows the number of rows being generated
|
|
805
|
-
* @param cols the number of columns being generated
|
|
806
|
-
* @param urng c++11-style random number generator
|
|
807
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
808
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
809
|
-
*/
|
|
810
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
811
|
-
inline const DiscreteDType<Derived, Urng>
|
|
812
|
-
discreteD(Index rows, Index cols, Urng&& urng, RealIter first, RealIter last)
|
|
813
|
-
{
|
|
814
|
-
return {
|
|
815
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, double>(std::forward<Urng>(urng), first, last)
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
821
|
-
* The data type used for calculation of probabilities is double(52bit precision).
|
|
822
|
-
*
|
|
823
|
-
* @tparam Derived
|
|
824
|
-
* @tparam Urng
|
|
825
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
826
|
-
* @param urng c++11-style random number generator
|
|
827
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
828
|
-
* @return a random matrix expression of the same shape as `o`
|
|
829
|
-
*/
|
|
830
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
831
|
-
inline const DiscreteDType<Derived, Urng>
|
|
832
|
-
discreteDLike(Derived& o, Urng&& urng, RealIter first, RealIter last)
|
|
833
|
-
{
|
|
834
|
-
return {
|
|
835
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, double>(std::forward<Urng>(urng), first, last)
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
841
|
-
* The data type used for calculation of probabilities is double(52bit precision).
|
|
842
|
-
*
|
|
843
|
-
* @tparam Derived
|
|
844
|
-
* @tparam Urng
|
|
845
|
-
* @param rows the number of rows being generated
|
|
846
|
-
* @param cols the number of columns being generated
|
|
847
|
-
* @param urng c++11-style random number generator
|
|
848
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
849
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
850
|
-
*/
|
|
851
|
-
template<typename Derived, typename Urng, typename Real>
|
|
852
|
-
inline const DiscreteDType<Derived, Urng>
|
|
853
|
-
discreteD(Index rows, Index cols, Urng&& urng, const std::initializer_list<Real>& il)
|
|
854
|
-
{
|
|
855
|
-
return {
|
|
856
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, double>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
857
|
-
};
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
862
|
-
* The data type used for calculation of probabilities is double(52bit precision).
|
|
863
|
-
*
|
|
864
|
-
* @tparam Derived
|
|
865
|
-
* @tparam Urng
|
|
866
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
867
|
-
* @param urng c++11-style random number generator
|
|
868
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
869
|
-
* @return a random matrix expression of the same shape as `o`
|
|
870
|
-
*/
|
|
871
|
-
template<typename Derived, typename Urng, typename Real>
|
|
872
|
-
inline const DiscreteDType<Derived, Urng>
|
|
873
|
-
discreteDLike(Derived& o, Urng&& urng, const std::initializer_list<Real>& il)
|
|
874
|
-
{
|
|
875
|
-
return {
|
|
876
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, double>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
template<typename Derived, typename Urng>
|
|
881
|
-
using DiscreteType = CwiseNullaryOp<internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, int32_t>, const Derived>;
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
885
|
-
* The data type used for calculation of probabilities is int32(32bit precision).
|
|
886
|
-
*
|
|
887
|
-
* @tparam Derived
|
|
888
|
-
* @tparam Urng
|
|
889
|
-
* @param rows the number of rows being generated
|
|
890
|
-
* @param cols the number of columns being generated
|
|
891
|
-
* @param urng c++11-style random number generator
|
|
892
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
893
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
894
|
-
*/
|
|
895
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
896
|
-
inline const DiscreteType<Derived, Urng>
|
|
897
|
-
discrete(Index rows, Index cols, Urng&& urng, RealIter first, RealIter last)
|
|
898
|
-
{
|
|
899
|
-
return {
|
|
900
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, int32_t>(std::forward<Urng>(urng), first, last)
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
/**
|
|
905
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
906
|
-
* The data type used for calculation of probabilities is int32(32bit precision).
|
|
907
|
-
*
|
|
908
|
-
* @tparam Derived
|
|
909
|
-
* @tparam Urng
|
|
910
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
911
|
-
* @param urng c++11-style random number generator
|
|
912
|
-
* @param first, last the range of elements defining the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
913
|
-
* @return a random matrix expression of the same shape as `o`
|
|
914
|
-
*/
|
|
915
|
-
template<typename Derived, typename Urng, typename RealIter>
|
|
916
|
-
inline const DiscreteType<Derived, Urng>
|
|
917
|
-
discreteLike(Derived& o, Urng&& urng, RealIter first, RealIter last)
|
|
918
|
-
{
|
|
919
|
-
return {
|
|
920
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, int32_t>(std::forward<Urng>(urng), first, last)
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
926
|
-
* The data type used for calculation of probabilities is int32(32bit precision).
|
|
927
|
-
*
|
|
928
|
-
* @tparam Derived
|
|
929
|
-
* @tparam Urng
|
|
930
|
-
* @param rows the number of rows being generated
|
|
931
|
-
* @param cols the number of columns being generated
|
|
932
|
-
* @param urng c++11-style random number generator
|
|
933
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
934
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
935
|
-
*/
|
|
936
|
-
template<typename Derived, typename Urng, typename Real>
|
|
937
|
-
inline const DiscreteType<Derived, Urng>
|
|
938
|
-
discrete(Index rows, Index cols, Urng&& urng, const std::initializer_list<Real>& il)
|
|
939
|
-
{
|
|
940
|
-
return {
|
|
941
|
-
rows, cols, internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, int32_t>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* @brief generates random integers on the interval `[0, n)`, where the probability of each individual integer `i` is proportional to `w(i)`.
|
|
947
|
-
* The data type used for calculation of probabilities is int32(32bit precision).
|
|
948
|
-
*
|
|
949
|
-
* @tparam Derived
|
|
950
|
-
* @tparam Urng
|
|
951
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
952
|
-
* @param urng c++11-style random number generator
|
|
953
|
-
* @param il an instance of `initializer_list` containing the numbers to use as weights. The type of the elements referred by `RealIter` must be convertible to `double`.
|
|
954
|
-
* @return a random matrix expression of the same shape as `o`
|
|
955
|
-
*/
|
|
956
|
-
template<typename Derived, typename Urng, typename Real>
|
|
957
|
-
inline const DiscreteType<Derived, Urng>
|
|
958
|
-
discreteLike(Derived& o, Urng&& urng, const std::initializer_list<Real>& il)
|
|
959
|
-
{
|
|
960
|
-
return {
|
|
961
|
-
o.rows(), o.cols(), internal::scalar_discrete_dist_op<typename Derived::Scalar, Urng, int32_t>(std::forward<Urng>(urng), il.begin(), il.end())
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
template<typename Derived, typename Urng>
|
|
966
|
-
using PoissonType = CwiseNullaryOp<internal::scalar_poisson_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
967
|
-
|
|
968
|
-
/**
|
|
969
|
-
* @brief generates reals on the Poisson distribution.
|
|
970
|
-
*
|
|
971
|
-
* @tparam Derived
|
|
972
|
-
* @tparam Urng
|
|
973
|
-
* @param rows the number of rows being generated
|
|
974
|
-
* @param cols the number of columns being generated
|
|
975
|
-
* @param urng c++11-style random number generator
|
|
976
|
-
* @param mean rate parameter
|
|
977
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
978
|
-
*/
|
|
979
|
-
template<typename Derived, typename Urng>
|
|
980
|
-
inline const PoissonType<Derived, Urng>
|
|
981
|
-
poisson(Index rows, Index cols, Urng&& urng, double mean = 1)
|
|
982
|
-
{
|
|
983
|
-
return {
|
|
984
|
-
rows, cols, internal::scalar_poisson_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean)
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
/**
|
|
989
|
-
* @brief generates reals on the Poisson distribution.
|
|
990
|
-
*
|
|
991
|
-
* @tparam Derived
|
|
992
|
-
* @tparam Urng
|
|
993
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
994
|
-
* @param urng c++11-style random number generator
|
|
995
|
-
* @param mean rate parameter
|
|
996
|
-
* @return a random matrix expression of the same shape as `o`
|
|
997
|
-
*/
|
|
998
|
-
template<typename Derived, typename Urng>
|
|
999
|
-
inline const PoissonType<Derived, Urng>
|
|
1000
|
-
poissonLike(Derived& o, Urng&& urng, double mean = 1)
|
|
1001
|
-
{
|
|
1002
|
-
return {
|
|
1003
|
-
o.rows(), o.cols(), internal::scalar_poisson_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), mean)
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
template<typename Derived, typename Urng>
|
|
1008
|
-
using BinomialType = CwiseNullaryOp<internal::scalar_binomial_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* @brief generates reals on the binomial distribution.
|
|
1012
|
-
*
|
|
1013
|
-
* @tparam Derived
|
|
1014
|
-
* @tparam Urng
|
|
1015
|
-
* @param rows the number of rows being generated
|
|
1016
|
-
* @param cols the number of columns being generated
|
|
1017
|
-
* @param urng c++11-style random number generator
|
|
1018
|
-
* @param trials the number of trials
|
|
1019
|
-
* @param p probability of a trial generating true
|
|
1020
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
1021
|
-
*/
|
|
1022
|
-
template<typename Derived, typename Urng>
|
|
1023
|
-
inline const BinomialType<Derived, Urng>
|
|
1024
|
-
binomial(Index rows, Index cols, Urng&& urng, typename Derived::Scalar trials = 1, double p = 0.5)
|
|
1025
|
-
{
|
|
1026
|
-
return {
|
|
1027
|
-
rows, cols, internal::scalar_binomial_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), trials, p)
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
/**
|
|
1032
|
-
* @brief generates reals on the binomial distribution.
|
|
1033
|
-
*
|
|
1034
|
-
* @tparam Derived
|
|
1035
|
-
* @tparam Urng
|
|
1036
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
1037
|
-
* @param urng c++11-style random number generator
|
|
1038
|
-
* @param trials the number of trials
|
|
1039
|
-
* @param p probability of a trial generating true
|
|
1040
|
-
* @return a random matrix expression of the same shape as `o`
|
|
1041
|
-
*/
|
|
1042
|
-
template<typename Derived, typename Urng>
|
|
1043
|
-
inline const BinomialType<Derived, Urng>
|
|
1044
|
-
binomialLike(Derived& o, Urng&& urng, typename Derived::Scalar trials = 1, double p = 0.5)
|
|
1045
|
-
{
|
|
1046
|
-
return {
|
|
1047
|
-
o.rows(), o.cols(), internal::scalar_binomial_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), trials, p)
|
|
1048
|
-
};
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
template<typename Derived, typename Urng>
|
|
1052
|
-
using NegativeBinomialType = CwiseNullaryOp<internal::scalar_negative_binomial_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
1053
|
-
|
|
1054
|
-
/**
|
|
1055
|
-
* @brief generates reals on the negative binomial distribution.
|
|
1056
|
-
*
|
|
1057
|
-
* @tparam Derived
|
|
1058
|
-
* @tparam Urng
|
|
1059
|
-
* @param rows the number of rows being generated
|
|
1060
|
-
* @param cols the number of columns being generated
|
|
1061
|
-
* @param urng c++11-style random number generator
|
|
1062
|
-
* @param trials the number of trial successes
|
|
1063
|
-
* @param p probability of a trial generating true
|
|
1064
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
1065
|
-
*/
|
|
1066
|
-
template<typename Derived, typename Urng>
|
|
1067
|
-
inline const NegativeBinomialType<Derived, Urng>
|
|
1068
|
-
negativeBinomial(Index rows, Index cols, Urng&& urng, typename Derived::Scalar trials = 1, double p = 0.5)
|
|
1069
|
-
{
|
|
1070
|
-
return {
|
|
1071
|
-
rows, cols, internal::scalar_negative_binomial_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), trials, p)
|
|
1072
|
-
};
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
* @brief generates reals on the negative binomial distribution.
|
|
1077
|
-
*
|
|
1078
|
-
* @tparam Derived
|
|
1079
|
-
* @tparam Urng
|
|
1080
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
1081
|
-
* @param urng c++11-style random number generator
|
|
1082
|
-
* @param trials the number of trial successes
|
|
1083
|
-
* @param p probability of a trial generating true
|
|
1084
|
-
* @return a random matrix expression of the same shape as `o`
|
|
1085
|
-
*/
|
|
1086
|
-
template<typename Derived, typename Urng>
|
|
1087
|
-
inline const NegativeBinomialType<Derived, Urng>
|
|
1088
|
-
negativeBinomialLike(Derived& o, Urng&& urng, typename Derived::Scalar trials = 1, double p = 0.5)
|
|
1089
|
-
{
|
|
1090
|
-
return {
|
|
1091
|
-
o.rows(), o.cols(), internal::scalar_negative_binomial_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), trials, p)
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
template<typename Derived, typename Urng>
|
|
1096
|
-
using GeometricType = CwiseNullaryOp<internal::scalar_geometric_dist_op<typename Derived::Scalar, Urng>, const Derived>;
|
|
1097
|
-
|
|
1098
|
-
/**
|
|
1099
|
-
* @brief generates reals on the geometric distribution.
|
|
1100
|
-
*
|
|
1101
|
-
* @tparam Derived
|
|
1102
|
-
* @tparam Urng
|
|
1103
|
-
* @param rows the number of rows being generated
|
|
1104
|
-
* @param cols the number of columns being generated
|
|
1105
|
-
* @param urng c++11-style random number generator
|
|
1106
|
-
* @param p probability of a trial generating true
|
|
1107
|
-
* @return a random matrix expression with a shape (`rows`, `cols`)
|
|
1108
|
-
*/
|
|
1109
|
-
template<typename Derived, typename Urng>
|
|
1110
|
-
inline const GeometricType<Derived, Urng>
|
|
1111
|
-
geometric(Index rows, Index cols, Urng&& urng, double p = 0.5)
|
|
1112
|
-
{
|
|
1113
|
-
return {
|
|
1114
|
-
rows, cols, internal::scalar_geometric_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), p)
|
|
1115
|
-
};
|
|
1116
|
-
}
|
|
1117
34
|
|
|
1118
|
-
/**
|
|
1119
|
-
* @brief generates reals on the geometric distribution.
|
|
1120
|
-
*
|
|
1121
|
-
* @tparam Derived
|
|
1122
|
-
* @tparam Urng
|
|
1123
|
-
* @param o an instance of any type of Eigen::DenseBase
|
|
1124
|
-
* @param urng c++11-style random number generator
|
|
1125
|
-
* @param p probability of a trial generating true
|
|
1126
|
-
* @return a random matrix expression of the same shape as `o`
|
|
1127
|
-
*/
|
|
1128
|
-
template<typename Derived, typename Urng>
|
|
1129
|
-
inline const GeometricType<Derived, Urng>
|
|
1130
|
-
geometricLike(Derived& o, Urng&& urng, double p = 0.5)
|
|
1131
|
-
{
|
|
1132
|
-
return {
|
|
1133
|
-
o.rows(), o.cols(), internal::scalar_geometric_dist_op<typename Derived::Scalar, Urng>(std::forward<Urng>(urng), p)
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
35
|
}
|
|
1137
36
|
}
|
|
1138
37
|
|