diff options
| author | ziejd2 | 2018-09-13 23:59:20 -0500 |
|---|---|---|
| committer | ziejd2 | 2018-09-13 23:59:20 -0500 |
| commit | e3f7237ffcb19f19db3b68777b5a94b89e07f66a (patch) | |
| tree | 554a8013776ebeae3e2976074020c09c2d1af8b0 /sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m | |
| parent | a7eb61ff7a09f39bee67014bf24b8919eaccfc19 (diff) | |
| download | BNW-e3f7237ffcb19f19db3b68777b5a94b89e07f66a.tar.gz | |
New parameter learning options
The main change here is in the parameter learning methods. The parameters that are learned at first (i.e., if there is no evidence) are the distributions that are found directly in the data. I had to create or significantly modify several BNT files for this. If there is evidence, the parameters are learned using a Dirichlet prior. This only required a couple of small changes to the BNW parameter learning files.
Diffstat (limited to 'sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m')
| -rw-r--r-- | sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m b/sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m new file mode 100644 index 00000000..c0948566 --- /dev/null +++ b/sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m @@ -0,0 +1,20 @@ +function CPD = learn_params_orig(CPD,j,data,ns,cnodes) +% LEARN_PARAMS_ORIG +% Calculate the original distributions of the data. +% The original distributions are just the percentages of states in the +% data file. + +local_data = data(j, :); +nobs = size(local_data,2); +if iscell(local_data) + local_data = cell2num(local_data); +end +counts = compute_counts(local_data,ns(j)); +counts = counts/nobs; +switch CPD.prior_type + case 'none', CPD.CPT_orig = counts; +% case 'dirichlet', CPD.CPT = mk_stochastic(counts + CPD.dirichlet); +% I will use 'dirichlet' priors incorrectly here. + case 'dirichlet', CPD.CPT_orig = counts; + otherwise, error(['unrecognized prior ' CPD.prior_type]) +end |
