Residual variance Exact formula

When I digged into brainstorm's git page, I found that Residual variance is computed as

sum(d1-d2).^2./ sum( d1.^2)

for example, if I want to calculate the goodness of fit of my simulated EEG recording with the actual recording, what is my d1 and d2.

Is d1 the actual recording, and d2 the simulated recording? or vice versa?

Hi @SubratBastola,

Indeed,

residual_variance = sum((d1-d2).^2) ./ sum(d1.^2)

with d1 being the recording and d2 the simulated data.

In Brainstorm, goodness of fit is computed as:

goodness_of_fit = 1 - residual_variance