Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of constraints #43

Open
GhostDeini opened this issue Nov 28, 2022 · 3 comments
Open

Use of constraints #43

GhostDeini opened this issue Nov 28, 2022 · 3 comments

Comments

@GhostDeini
Copy link

Hi, is it possible to add a constraint for the MCR ALS method such that the first value of one of the concentration profiles must be equal to 1?

@CCampJr
Copy link
Collaborator

CCampJr commented Nov 28, 2022

@GhostDeini Yes it is, thanks for asking!

The easiest way is to provide an initial guess of concentration numbers in the fit method -- setting the first entry to 1.0 -- then use the c_fix=[0] to fix the first concentration profile.

Example:

# D is your data of the shape (M,N)

M, N = D.shape
N_chemicals = 5  # I think or know there are 5 chemical species
# C_init is your concentration matrix of size (M, N_chemicals)
C_init = np.random.rand(M, N_chemical)
C_init[:,0] = 1.0

mcrar = McrAr()
mcrar.fit(D, C=C_init, c_fix=[0])

Does that answer your questions, and anything else I can help you with?

@GhostDeini
Copy link
Author

I keep getting this error when I give initial estimates for the concentration profiles:

Error increased above fractionalctol_increase (C iter). Exiting

Is it possible to give initial estimates for the spectra and also the mentioned constraint for the concentrations?

Thank you.

@CCampJr
Copy link
Collaborator

CCampJr commented Nov 28, 2022

You have a few options. You can increase the tol_increase in the instantiation of McrAr:
mcrar = McrAr(tol_increase=10.) # 1000% increase in err metric allowed

You can absolutely input an S=S_init and C=C_init and you probably have to select c_first=True or False in the fit method. There are a few other solutions I can think of, but maybe if I understand your use-case a little more, I can come up with a solution. Feel free to post more here or send me an email to charles.camp@nist.gov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants