.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/uncertainty/sensitivity/plot_create_sensitivity_analysis.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_examples_uncertainty_sensitivity_plot_create_sensitivity_analysis.py: Create sensitivity analysis =========================== :func:`.create_sensitivity_analysis` is a top-level function to create a sensitivity analysis from a sensitivity analysis class name, e.g. ``"MorrisAnalysis"``. .. GENERATED FROM PYTHON SOURCE LINES 24-31 .. code-block:: Python from __future__ import annotations from gemseo.problems.uncertainty.ishigami.ishigami_discipline import IshigamiDiscipline from gemseo.problems.uncertainty.ishigami.ishigami_space import IshigamiSpace from gemseo.uncertainty import create_sensitivity_analysis .. GENERATED FROM PYTHON SOURCE LINES 32-36 There are two ways of using :func:`.create_sensitivity_analysis`. The first one is to perform a sensitivity analysis from a collection of disciplines and an uncertain space: .. GENERATED FROM PYTHON SOURCE LINES 36-43 .. code-block:: Python analysis = create_sensitivity_analysis("MorrisAnalysis") uncertain_space = IshigamiSpace() discipline = IshigamiDiscipline() samples = analysis.compute_samples([discipline], uncertain_space, n_samples=0) indices = analysis.compute_indices() indices .. rst-class:: sphx-glr-script-out .. code-block:: none INFO - 16:22:31: *** Start MorrisAnalysisSamplingPhase execution *** INFO - 16:22:31: MorrisAnalysisSamplingPhase INFO - 16:22:31: Disciplines: IshigamiDiscipline INFO - 16:22:31: MDO formulation: MDF INFO - 16:22:31: Running the algorithm MorrisDOE: INFO - 16:22:31: 5%|▌ | 1/20 [00:00<00:00, 474.04 it/sec] INFO - 16:22:31: 10%|█ | 2/20 [00:00<00:00, 795.66 it/sec] INFO - 16:22:31: 15%|█▌ | 3/20 [00:00<00:00, 1056.77 it/sec] INFO - 16:22:31: 20%|██ | 4/20 [00:00<00:00, 1272.93 it/sec] INFO - 16:22:31: 25%|██▌ | 5/20 [00:00<00:00, 1469.42 it/sec] INFO - 16:22:31: 30%|███ | 6/20 [00:00<00:00, 1643.43 it/sec] INFO - 16:22:31: 35%|███▌ | 7/20 [00:00<00:00, 1781.13 it/sec] INFO - 16:22:31: 40%|████ | 8/20 [00:00<00:00, 1852.81 it/sec] INFO - 16:22:31: 45%|████▌ | 9/20 [00:00<00:00, 1967.21 it/sec] INFO - 16:22:31: 50%|█████ | 10/20 [00:00<00:00, 2066.57 it/sec] INFO - 16:22:31: 55%|█████▌ | 11/20 [00:00<00:00, 2154.94 it/sec] INFO - 16:22:31: 60%|██████ | 12/20 [00:00<00:00, 2229.04 it/sec] INFO - 16:22:31: 65%|██████▌ | 13/20 [00:00<00:00, 2312.68 it/sec] INFO - 16:22:31: 70%|███████ | 14/20 [00:00<00:00, 2381.10 it/sec] INFO - 16:22:31: 75%|███████▌ | 15/20 [00:00<00:00, 2444.61 it/sec] INFO - 16:22:31: 80%|████████ | 16/20 [00:00<00:00, 2499.96 it/sec] INFO - 16:22:31: 85%|████████▌ | 17/20 [00:00<00:00, 2563.57 it/sec] INFO - 16:22:31: 90%|█████████ | 18/20 [00:00<00:00, 2616.35 it/sec] INFO - 16:22:31: 95%|█████████▌| 19/20 [00:00<00:00, 2664.30 it/sec] INFO - 16:22:31: 100%|██████████| 20/20 [00:00<00:00, 2663.73 it/sec] INFO - 16:22:31: *** End MorrisAnalysisSamplingPhase execution *** MorrisAnalysis.SensitivityIndices(mu={'y': [{'x1': array([-0.60047199]), 'x2': array([0.51230435]), 'x3': array([-0.89800793])}]}, mu_star={'y': [{'x1': array([0.69887482]), 'x2': array([0.65136343]), 'x3': array([0.89805157])}]}, sigma={'y': [{'x1': array([0.96395158]), 'x2': array([0.6549141]), 'x3': array([0.79878356])}]}, relative_sigma={'y': [{'x1': array([1.37929075]), 'x2': array([1.00545113]), 'x3': array([0.88946291])}]}, min={'y': [{'x1': array([0.0338188]), 'x2': array([0.11821721]), 'x3': array([8.72820113e-05])}]}, max={'y': [{'x1': array([2.2360336]), 'x2': array([1.25769934]), 'x3': array([2.12052546])}]}) .. GENERATED FROM PYTHON SOURCE LINES 44-50 The ``samples`` can be saved on the disk using the :func:`.to_pickle` function, e.g. ``to_pickle(sample, "my_samples.p")``, in order to use them later to compute sensitivity indices. The other way is to perform a sensitivity analysis from samples computed from another sensitivity analysis: .. GENERATED FROM PYTHON SOURCE LINES 50-54 .. code-block:: Python analysis = create_sensitivity_analysis("MorrisAnalysis", samples=samples) indices = analysis.compute_indices() indices .. rst-class:: sphx-glr-script-out .. code-block:: none MorrisAnalysis.SensitivityIndices(mu={'y': [{'x1': array([-0.60047199]), 'x2': array([0.51230435]), 'x3': array([-0.89800793])}]}, mu_star={'y': [{'x1': array([0.69887482]), 'x2': array([0.65136343]), 'x3': array([0.89805157])}]}, sigma={'y': [{'x1': array([0.96395158]), 'x2': array([0.6549141]), 'x3': array([0.79878356])}]}, relative_sigma={'y': [{'x1': array([1.37929075]), 'x2': array([1.00545113]), 'x3': array([0.88946291])}]}, min={'y': [{'x1': array([0.0338188]), 'x2': array([0.11821721]), 'x3': array([8.72820113e-05])}]}, max={'y': [{'x1': array([2.2360336]), 'x2': array([1.25769934]), 'x3': array([2.12052546])}]}) .. GENERATED FROM PYTHON SOURCE LINES 55-58 The argument ``samples`` of :func:`.create_sensitivity_analysis` can be either an :class:`.IODataset` as above or a pickle file path, e.g. ``create_sensitivity_analysis("MorrisAnalysis", samples="my_samples.p")``. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.034 seconds) .. _sphx_glr_download_examples_uncertainty_sensitivity_plot_create_sensitivity_analysis.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_create_sensitivity_analysis.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_create_sensitivity_analysis.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_create_sensitivity_analysis.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_