MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / randn

Function randn

utils/array_utils.hpp:213–219  ·  view source on GitHub ↗

* @brief Populate the array with random floats, generated from a Gaussian distribution. * @param a The array to populate. * @param N The number of elements in the array. * @param gen The random number generator. * @param mean The mean of the Gaussian distribution. * @param std The standard deviation of the Gaussian distribution. */

Source from the content-addressed store, hash-verified

211 * @param std The standard deviation of the Gaussian distribution.
212 */
213inline void randn(float *a, size_t N, std::mt19937 &gen, float mean = 0.0,
214 float std = 1.0) {
215 std::normal_distribution<float> dist(mean, std);
216 for (int i = 0; i < N; i++) {
217 a[i] = static_cast<float>(dist(gen));
218 }
219}
220
221inline void randn(half *a, size_t N, std::mt19937 &gen, float mean = 0.0,
222 float std = 1.0) {

Callers 2

initDataFunction · 0.85
initDataFunction · 0.85

Calls 1

halfFromFloatFunction · 0.85

Tested by

no test coverage detected