Some background: I have a B.S. in physics. I have taken linear algebra. I do work that involves doing image analysis in IDL.
One thing I have to do a lot is fit a linear equation $(y=mx+b)$ to the number of electronic counts accumulated in each pixel over a series of frames. So, usually I'm working with something like an array that's $4096\times 4096\times 100$. Until now I've been just running a for loop where I input the hundred values for each pixel and a time vector into a linfit or regress function which spits out the linear fit. I then write the slope of that fit to a new $4096\times 4096 $ image which shows the rate each pixel accumulates counts/charge. It works, but a for loop that runs $16$ million times is slow in IDL.
Now, of course this is not a new problem and I found a nice procedure written by someone at the Space Telescope Science Institute that does the same thing as above but with really fast matrix multiplication. I've tested it and it gives the results I expect. Problem is that I don't understand how it works, and so can't modify it to fit my needs.
As far as I can tell the program is using this linear regression using matrices:
Linear Regression in Matrix Form
Unfortunately, I struggle with matrices; thus, I can't make any sense of what's happening.
There's the added difficulty that to do this in IDL the $4096\times 4096\times N$ array is turned into a $4096*4096\times N$ array (that is ~$16.7$million by $N$) and I'm not quite sure why.
So, can anyone explain what this matrix math is doing in extremely simple terms? For bonus points, avoid using terms like "null", "kernel", "space", and try not to just post a long series of formulas as my eyes will probably just glaze over. As a preemptive against those who might tell me that I need to study more Linear Algebra: I have and I aced the undergrad class. I have no problem with the mechanics of it. I just don't understand the underlying motivation and concepts of linear algebra.
Here is a link to the code: ramp_basiclinfit.pro
I know exactly what you need. Here it is the answer to your problems: https://www.youtube.com/watch?v=dkfY0OKH12g