compute_single_fidelity_and_approximate_control_variate_mean_estimates¶
-
pyapprox.control_variate_monte_carlo.
compute_single_fidelity_and_approximate_control_variate_mean_estimates
(nhf_samples, nsample_ratios, model_ensemble, generate_samples, generate_samples_and_values, cov, get_cv_weights, seed)[source]¶ Compute the approximate control variate estimate of a high-fidelity model from using it and a set of lower fidelity models. Also compute the single fidelity Monte Carlo estimate of the mean from only the high-fidelity data.
Notes
To create reproducible results when running numpy.random in parallel must use RandomState. If not the results will be non-deterministic. This is happens because of a race condition. numpy.random.* uses only one global PRNG that is shared across all the threads without synchronization. Since the threads are running in parallel, at the same time, and their access to this global PRNG is not synchronized between them, they are all racing to access the PRNG state (so that the PRNG’s state might change behind other threads’ backs). Giving each thread its own PRNG (RandomState) solves this problem because there is no longer any state that’s shared by multiple threads without synchronization. Also see new features https://docs.scipy.org/doc/numpy/reference/random/parallel.html https://docs.scipy.org/doc/numpy/reference/random/multithreading.html