# How “The PARAFAC model is found”

The PARAFAC model is found as
`Factors = PARAFAC(Xnew,3);`

The factors of the model are held in Factors where the scores are located in
`A = Factors{1};`

There are three components
One of them correspond to tryptophan, but which?

If you take a look in y, you will see that the calibration sample
(the one with ‘known’ concentration) is a pure sample, only containing tryptophan).
So that means that in the first row of A we only expect one of the three scores to be
non-zero. In reality, the scores will not be exactly zero, but the column in which the highest element is present must be the one corresponding to tryptophan.

Assume that this is column 2. Then `A(:,2)` must the be score vector having the estimated relative concentration of tryptophan in the samples.

We then have to scale these concentration estimates so that they are in M or mM.
This is simple. We know the concentration in the first sample, so we just have to scale `A(:,2)` such that the first element is equal to the true concentration  `y(1,1)`.

Hence, `y_trp = A(:,2)*(y(1,1)/A(1,2))`

(Why `A(:,2)/A(1,2)`will turn the first element into one and then multiplying with `y(1,1)`, the first score will be identical to the real concentration. Hence, the scores are now scaled to M)

must be an estimate of the tryptophan concentrations in the samples.