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

MRG, BUG: Fix biased cov estimation #7369

Merged
merged 7 commits into from
Mar 3, 2020
Merged

Conversation

larsoner
Copy link
Member

@larsoner larsoner commented Mar 2, 2020

We have an inconsistency where MNE-C and MNE-Python with method='empirical' would compute an unbiased estimator of the covariance, but any other mode would compute a biased estimator (the maximum likelihood estimator). This PR makes us always compute the unbiased one.

We could alternatively add a bias kwarg to compute_covariance and compute_raw_covariance with a deprecation cycle for people. But I'm not sure it's worth it because in practice the scale factor should be quite small as it is N / (N - 1) where N is the number of (time) samples used to compute the covariance, which is typically quite large.

@codecov
Copy link

codecov bot commented Mar 2, 2020

Codecov Report

Merging #7369 into master will increase coverage by 0.08%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #7369      +/-   ##
==========================================
+ Coverage   89.98%   90.07%   +0.08%     
==========================================
  Files         453      453              
  Lines       81994    81204     -790     
  Branches    12994    12998       +4     
==========================================
- Hits        73785    73145     -640     
+ Misses       5382     5231     -151     
- Partials     2827     2828       +1

@agramfort agramfort merged commit c5aa0b8 into mne-tools:master Mar 3, 2020
@agramfort
Copy link
Member

thx heaps @larsoner !

@larsoner larsoner deleted the cov branch March 3, 2020 23:24
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* BUG: Fix biased cov estimation

* FIX: Minor fix

* FIX: Link

* FIX: Dont require sklearn

* FIX: sklearn check

* MAINT: Simplify check

* FIX: Flake
AdoNunes pushed a commit to AdoNunes/mne-python that referenced this pull request Apr 6, 2020
* BUG: Fix biased cov estimation

* FIX: Minor fix

* FIX: Link

* FIX: Dont require sklearn

* FIX: sklearn check

* MAINT: Simplify check

* FIX: Flake
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

Successfully merging this pull request may close these issues.

2 participants