.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_ica_synth.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_ica_synth.py: ================================================= Blind source separation using Picard and Picard-O ================================================= The example runs the Picard algorithm proposed in: Pierre Ablin, Jean-Francois Cardoso, Alexandre Gramfort "Faster independent component analysis by preconditioning with Hessian approximations" IEEE Transactions on Signal Processing, 2018 https://arxiv.org/abs/1706.08171 and Picard-O algorithm proposed in: Pierre Ablin, Jean-François Cardoso, Alexandre Gramfort "Faster ICA under orthogonal constraint" ICASSP, 2018 https://arxiv.org/abs/1711.10873 .. GENERATED FROM PYTHON SOURCE LINES 21-33 .. code-block:: default # Author: Pierre Ablin # Alexandre Gramfort # License: BSD 3 clause import numpy as np import matplotlib.pyplot as plt from picard import picard print(__doc__) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Generate sample data .. GENERATED FROM PYTHON SOURCE LINES 35-54 .. code-block:: default np.random.seed(0) n_samples = 2000 time = np.linspace(0, 8, n_samples) s1 = np.sin(2 * time) * np.sin(40 * time) s2 = np.sin(3 * time) ** 5 s3 = np.random.laplace(size=s1.shape) S = np.c_[s1, s2, s3].T S /= S.std(axis=1)[:, np.newaxis] # Standardize data # Mix data A = np.array([[1, 1, 1], [0.5, 2, 1.0], [1.5, 1.0, 2.0]]) # Mixing matrix X = np.dot(A, S) # Generate observations # Compute ICA _, _, Y_picard = picard(X, ortho=False, random_state=0) _, _, Y_picardo = picard(X, ortho=True, random_state=0) .. GENERATED FROM PYTHON SOURCE LINES 55-56 Plot results .. GENERATED FROM PYTHON SOURCE LINES 56-71 .. code-block:: default models = [X, S, Y_picard, Y_picardo] names = ['Observations (mixed signal)', 'True Sources', 'ICA recovered signals with Picard', 'ICA recovered signals with Picard-O'] colors = ['red', 'steelblue', 'orange'] for ii, (model, name) in enumerate(zip(models, names), 1): fig, axes = plt.subplots(3, 1, figsize=(6, 4), sharex=True, sharey=True) plt.suptitle(name) for ax, sig, color in zip(axes, model, colors): ax.plot(sig, color=color) plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_plot_ica_synth_001.png :alt: Observations (mixed signal) :srcset: /auto_examples/images/sphx_glr_plot_ica_synth_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_plot_ica_synth_002.png :alt: True Sources :srcset: /auto_examples/images/sphx_glr_plot_ica_synth_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_plot_ica_synth_003.png :alt: ICA recovered signals with Picard :srcset: /auto_examples/images/sphx_glr_plot_ica_synth_003.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_plot_ica_synth_004.png :alt: ICA recovered signals with Picard-O :srcset: /auto_examples/images/sphx_glr_plot_ica_synth_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.615 seconds) .. _sphx_glr_download_auto_examples_plot_ica_synth.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_ica_synth.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ica_synth.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_