Skip to content

Instantly share code, notes, and snippets.

@davidchall
Created March 16, 2016 21:18
Show Gist options
  • Save davidchall/f58781741e74006c63e9 to your computer and use it in GitHub Desktop.
Save davidchall/f58781741e74006c63e9 to your computer and use it in GitHub Desktop.

Revisions

  1. davidchall created this gist Mar 16, 2016.
    6 changes: 6 additions & 0 deletions weighted_mean.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    Given a set of covariance matrices `pcov` of shape (n,m,m) and a set of parameter estimates `popt` of shape (n,m), the mean parameter estimates are:

    weight = np.linalg.inv(pcov)
    pcov_mean = np.linalg.inv(np.sum(weight, axis=0))
    popt_wgt = np.einsum('ijk,ik->ij', weight, popt)
    popt_mean = np.dot(pcov_mean, np.sum(popt_wgt, axis=0))