September 18, 2013

Running covariance confirmation for model_type = 3.

Results don't match.

Off-diagonals are okay.

on-diagonal's are larger in reference impl; on order of 10.

Reference implementation has all positive eigenvalues. Likely bug is in testing implementation.

**Open question: Does branch_index need to be incremented by start_index?**

also, is prior_K including start_index?

Root curve is block incorrect, which means we can focus on either `build_root_object`

or `build_sibling block`

.

**Got it**: prior_K was computed with model_type = 1. It contains no perturb covariance. But root block does contain perturb covariance.

Re-attach using:

```
wacv_Corrs_ratt = wacv_Corrs;
for i = 1:numel(wacv_Corrs_reatt)
C = wacv_Corrs_reatt{i};
wacv_Corrs_reatt = attach_2(wacv_Corrs_reatt, i, C.parent_ci, C.start_index, C.branch_index,params);
end
```

Now results are identical for the testing set

results differ on the full set.

in testing set, all branches occured from the zero point on the parent. the full set has branches from other points, and we're getting different results.

Found the cause of the problem: it was leftover cruft code I added during debugging. Caused non-symmetric matrix.

TODO: Move "confirm full covariance against reference implementation" into its own test folder

TODO: handle nonzero start-index in branching. re-run confirmation

TODO: finish "confirm curve-tree ML against reference implementation"

Struggling with curve_ml5, where Chol is failing. Looks like the problem is in att_Set_Branch_index; branch conditional covariance is not positive definite.

Found: indexing bug in `attachment/attach_2.m`

Comparing three methods:

```
% method 1
ml1 = curve_tree_ml_ref(wacv_Corrs_reatt, params, data_)
% method 2
ml2 = curve_tree_ml(wacv_Corrs_reatt, params, data_)
% method 3
ml3 = 0;
for i = 1:numel(wacv_Corrs_reatt)
ml = ml + curve_ml5( ...
wacv_Corrs_reatt{i}, ...
data_, ...
params, ...
get_model_kernel(params, params.model_type), ...
params.ml_block_size, ...
params.ml_markov_order);
end
```

All three currently differ significantly.

Also compared against an indendent model, whose ML was about 300 points lower.

At this point, method 2 and method 3 should be giving the same results, but aren't.

Moved covariance matrix test to `test/test_construct_attachment_covariance.m`

.

Re-ran and now it's failing :-/

Modified it to save the output; re-running to debug.

Needed to re-run `attach_2()`

, because prior_K was stale

TODO:

- troubleshoot covariance test
- investigate difference between method 2 and method 3 above.
- handle nonzero start-index in branching. re-run confirmation
- ground truth - trace datasets 7 through 10
- retrain using attachment