MCPcopy Create free account
hub / github.com/ml-explore/mlx / complex_normal

Function complex_normal

mlx/random.cpp:152–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152inline array complex_normal(
153 Shape shape,
154 const std::optional<array>& loc,
155 const std::optional<array>& scale,
156 const std::optional<array>& key,
157 StreamOrDevice s) {
158 auto stream = to_stream(s);
159 auto low = array(std::nextafter(-1.0f, 0.0f), float32);
160 auto high = array(1.0f, float32);
161 shape.push_back(2);
162 auto samples =
163 erfinv(uniform(low, high, shape, float32, key, stream), stream);
164 samples = squeeze(view(samples, complex64, stream), -1, stream);
165 if (scale.has_value()) {
166 samples = multiply(*scale, samples, stream);
167 }
168 if (loc.has_value()) {
169 samples = add(*loc, samples, stream);
170 }
171 return samples;
172}
173
174array normal(
175 const Shape& shape,

Callers 1

normalFunction · 0.85

Calls 9

to_streamFunction · 0.85
squeezeFunction · 0.85
viewFunction · 0.85
multiplyFunction · 0.85
addFunction · 0.85
push_backMethod · 0.80
arrayFunction · 0.70
erfinvFunction · 0.70
uniformFunction · 0.70

Tested by

no test coverage detected