25template <
typename AFloat_t>
28template<
typename AFloat>
31 if (!fgRandomGen) fgRandomGen =
new TRandom3();
32 fgRandomGen->SetSeed(seed);
34template<
typename AFloat>
37 if (!fgRandomGen) fgRandomGen =
new TRandom3(0);
42template<
typename AFloat>
45 size_t n =
A.GetNcols();
47 TRandom & rand = GetRandomGenerator();
51 for (
size_t i = 0; i <
A.GetSize(); ++i) {
52 A.GetRawDataPointer()[i] = rand.
Gaus(0.0,
sigma);
57template<
typename AFloat>
61 size_t n =
A.GetNcols();
63 TRandom & rand = GetRandomGenerator();
65 AFloat range =
sqrt(2.0 / ((AFloat)
n));
71 for (
size_t i = 0; i <
A.GetSize(); ++i) {
72 A.GetRawDataPointer()[i] = rand.
Uniform(-range, range);
81template<
typename AFloat>
90 TRandom & rand = GetRandomGenerator();
92 AFloat
sigma =
sqrt(2.0 /( ((AFloat)
n) + ((AFloat)
m)) );
95 size_t nsize =
A.GetSize();
96 for (
size_t i = 0; i < nsize; i++) {
100 }
while (std::abs(value) > 2 *
sigma);
102 A.GetRawDataPointer()[i] = value;
111template<
typename AFloat>
118 TRandom & rand = GetRandomGenerator();
120 AFloat range =
sqrt(6.0 /( ((AFloat)
n) + ((AFloat)
m)) );
122 size_t nsize =
A.GetSize();
123 for (
size_t i = 0; i < nsize; i++) {
124 A.GetRawDataPointer()[i] = rand.
Uniform(-range, range);
129template<
typename AFloat>
136 for (
size_t i = 0; i <
m; i++) {
137 for (
size_t j = 0; j <
n ; j++) {
149template<
typename AFloat>
156 for (
size_t i = 0; i <
m; i++) {
157 for (
size_t j = 0; j <
n ; j++) {
static TRandom * fgRandomGen
static void InitializeIdentity(Matrix_t &A)
static TRandom & GetRandomGenerator()
static void InitializeUniform(Matrix_t &A)
static void SetRandomSeed(size_t seed)
static void InitializeGauss(Matrix_t &A)
static void InitializeGlorotUniform(Matrix_t &A)
Sample from a uniform distribution in range [ -lim,+lim] where lim = sqrt(6/N_in+N_out).
static void InitializeGlorotNormal(Matrix_t &A)
Truncated normal initialization (Glorot, called also Xavier normal) The values are sample with a norm...
static void InitializeZero(Matrix_t &A)
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
create variable transformations