MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / simulate

Function simulate

batch/parallel/application/src/finsim.cc:55–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55double simulate(InputConfig const& config) {
56 double updated_price = config.price;
57 thread_local static std::mt19937 generator(std::random_device{}());
58 std::uniform_real_distribution<> dis(-1 * config.deviation, config.deviation);
59
60 for (int j = 0; j < config.iterations; ++j) {
61 updated_price =
62 updated_price * (1 + ((config.variance + dis(generator)) * 0.01));
63 }
64 return updated_price;
65}
66
67int main(int argc, char* argv[]) {
68 if (argc < 2) {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected