.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_parameter_sweeps.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_parameter_sweeps.py: Parameter Sweeps ---------------- When analyzing complex models or functions it is often useful to gain insight into its smoothness and non-linearity before undertaking more computationally intensive analysis such as uncertainty quantification or sensitivity analysis. Knowledge about smoothness and non-linearity can be used to inform what algorithms are used for these later tasks. Lets first generate parameter sweeps for the oakley benchmark. Each sweep will be a random direction through the parameter domain. The domain is assumed to be the cartesian product of the centered truncated intervals of each 1D variable marginal. For unbounded variables each interval captures 99% of the PDF. For bounded variables the true bounds are used (i.e. are not truncated) .. GENERATED FROM PYTHON SOURCE LINES 16-28 .. code-block:: default from pyapprox import analysis from pyapprox.util.visualization import plt, mathrm_label from pyapprox.benchmarks import setup_benchmark import numpy as np np.random.seed(1) benchmark = setup_benchmark("oakley") axs = analysis.generate_parameter_sweeps_and_plot_from_variable( benchmark.fun, benchmark.variable, num_samples_per_sweep=20, num_sweeps=3) plt.gcf().suptitle(mathrm_label("Oakely model parameter sweeps")) plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_parameter_sweeps_001.png :alt: $\mathrm{Oakely\;model\;parameter\;sweeps}$, $\mathrm{QoI\;0}$ :srcset: /auto_examples/images/sphx_glr_plot_parameter_sweeps_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 29-30 Now lets plot parameter sweeps for the Sobol G function .. GENERATED FROM PYTHON SOURCE LINES 30-36 .. code-block:: default benchmark = setup_benchmark("sobol_g", nvars=4) axs = analysis.generate_parameter_sweeps_and_plot_from_variable( benchmark.fun, benchmark.variable, num_samples_per_sweep=50, num_sweeps=3) plt.gcf().suptitle(mathrm_label("Sobol G model parameter sweeps")) plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_parameter_sweeps_002.png :alt: $\mathrm{Sobol\;G\;model\;parameter\;sweeps}$, $\mathrm{QoI\;0}$ :srcset: /auto_examples/images/sphx_glr_plot_parameter_sweeps_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [2.10729798e-04 2.16355425e-01 4.96284418e-04 4.46077822e-05] [0.99978927 0.78364457 0.99950372 0.99995539] .. GENERATED FROM PYTHON SOURCE LINES 37-40 The Sobol G function is not as smooth as the Oakely function. The former has discontinuous first derivatives which can be seen by inspecting their aprameter sweeps .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.125 seconds) .. _sphx_glr_download_auto_examples_plot_parameter_sweeps.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_parameter_sweeps.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_parameter_sweeps.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_