Notebook
Fast ICA is a version of independent component analysis developed by A. Hyvarinen and E. Oja. In trying to understand how ICA can be used, I created this notebook.ICA is used to find components that contribute to a joint signal. An analogy that is often used is to use several microphones to distinguish the contributions of each instrument to a symphony. You need to have as many microphones as there instruments. I guess it would help if the microphones capture the signals from maximally different locations.First we import some stuff.
Here we will create 'recordings' from two microphones of two separate 'instruments'. We start by creating two signals, one from each instrument.
Then we mix them into two different 'recordings', each with their own noise added.
Now we will use ICA to try to recover the two original instruments. We have to initialize an ICA object, telling it at least how many components (source 'instruments') to use. The data has to be transposed for FastICA to be able to use it.
We could now recover the sources.
If you plot this, notice that the scale is completely off, it could even be inverted for one or more sources and the instruments could be switched in order. However, the main characteristics of the two 'instruments' are very clear, even though the signals are noisy. Supposedly this scales well with more and more 'instruments' which is good for my purposes. However, I'm more interested in recreating the recordings minus one of the sources. Since we have only two 'instruments' that would look the same as recovering one of them, but I'm hoping to get appropriately scaled signals.
The columns are the source components (instruments), and the rows are the measured features (recordings). The numbers are the relative weights of the instruments in the recordings. I will set one instrument to zero and then multiply it with the reconstructed sources matrix, so that only one signal (instrument) is left.
If the first component is the sinusoid signal, the second recording should have a lower amplitude (one third of the first). If it is the square wave the second recording should have a higher amplitude (10% higher than the first). Using ICA this way, signals that are not interesting to you can be removed from data.