about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/CPDs/@tabular_CPD/learn_params_orig.m
diff options
context:
space:
mode:
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.m20
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