MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / randVector

Function randVector

src/utilities/data/Vector.cpp:197–213  ·  view source on GitHub ↗

generates a Vector of N points randomly drawn between and including a and b.

Source from the content-addressed store, hash-verified

195
196/// generates a Vector of N points randomly drawn between and including a and b.
197Vector randVector(double a, double b, unsigned N) {
198 // seed random number generator
199 static std::minstd_rand generator(42u);
200
201 // define distribution
202 boost::uniform_real<> dist(a, b);
203
204 // create a generator
205 boost::variate_generator<std::minstd_rand&, boost::uniform_real<>> uniformGenerator(generator, dist);
206
207 Vector result(N);
208 for (unsigned n = 0; n < N; ++n) {
209 result(n) = uniformGenerator(); // draw from generator
210 }
211
212 return result;
213}
214
215/// generates a Vector of N points linearly spaced between and including a and b.
216Vector linspace(double a, double b, unsigned N) {

Callers 2

SetUpTestSuiteMethod · 0.85
TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by 2

SetUpTestSuiteMethod · 0.68
TEST_FFunction · 0.68