I would like to apologise in advance for how wordy this problem is: I have experience with MATLAB but am relatively new to Python, and as such I am unable to express this problem in code where it would be more appropriate than describing using words.
I have a measured spectrum which consists of contributions from two components: A and B.
The absorbance at a given value of x is therefore:
Abs(x) ~ c*[(f*A(x))+((1-f)*B(x)],
where f is the fraction of A in the mixture, and c is proportional to the total concentration of A and B. The absorbance is only approximate because of noise in the measured spectrum.
Absorbance of individual components
Absorbance of mixture with noise
The question I have is how best to deconvolute the measured spectrum (over the entire range of x values) by determining the relative contribution of each component, and calculate the concentration of A + B - i.e., determine the combination of values for c and f in the equation above which give the best fit.
As a novice, a method which should work but which is inefficient would be to choose values of f at different intervals (say, 0 to 1 in 0.1 intervals) and find the value of c which gives the smallest sum of residuals squared, R^2 for each f. The combination which gives the best fit could then be used as an initial guess to optimise f to a chosen number of significant figures. I imagine however, that this approach would be time-intensive when running for loops with >thousands of spectra at a time.
Does Python contain any functionality which would allow for this deconvolution to be done more efficiently than the process described above, either in part or in whole?
Thanks in advance.