Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_CPD/set_fields.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function CPD = set_fields(CPD, varargin) | |
2 % SET_PARAMS Set the parameters (fields) for a tabular_CPD object | |
3 % CPD = set_params(CPD, name/value pairs) | |
4 % | |
5 % The following optional arguments can be specified in the form of name/value pairs: | |
6 % | |
7 % CPT, prior, clamped, counts | |
8 % | |
9 % e.g., CPD = set_params(CPD, 'CPT', 'rnd') | |
10 | |
11 args = varargin; | |
12 nargs = length(args); | |
13 for i=1:2:nargs | |
14 switch args{i}, | |
15 case 'CPT', | |
16 if ischar(args{i+1}) | |
17 switch args{i+1} | |
18 case 'unif', CPD.CPT = mk_stochastic(myones(CPD.sizes)); | |
19 case 'rnd', CPD.CPT = mk_stochastic(myrand(CPD.sizes)); | |
20 otherwise, error(['invalid type ' args{i+1}]); | |
21 end | |
22 elseif isscalarBNT(args{i+1}) | |
23 p = args{i+1}; | |
24 k = CPD.sizes(end); | |
25 % Bug fix by Hervé Boutrouille 10/1/01 | |
26 CPD.CPT = myreshape(sample_dirichlet(p*ones(1,k), prod(CPD.sizes(1:end-1)), CPD.sizes)); | |
27 %CPD.CPT = myreshape(sample_dirichlet(p*ones(1,k), prod(CPD.sizes(1:end-1))), CPD.sizes); | |
28 else | |
29 CPD.CPT = myreshape(args{i+1}, CPD.sizes); | |
30 end | |
31 | |
32 case 'prior', | |
33 if ischar(args{i+1}) & strcmp(args{i+1}, 'unif') | |
34 CPD.prior = myones(CPD.sizes); | |
35 elseif isscalarBNT(args{i+1}) | |
36 CPD.prior = args{i+1} * normalise(myones(CPD.sizes)); | |
37 else | |
38 CPD.prior = myreshape(args{i+1}, CPD.sizes); | |
39 end | |
40 | |
41 %case 'clamped', CPD.clamped = strcmp(args{i+1}, 'yes'); | |
42 %case 'clamped', CPD = set_clamped(CPD, strcmp(args{i+1}, 'yes')); | |
43 case 'clamped', CPD = set_clamped(CPD, args{i+1}); | |
44 | |
45 case 'counts', CPD.counts = args{i+1}; | |
46 | |
47 otherwise, | |
48 %error(['invalid argument name ' args{i}]); | |
49 end | |
50 end | |
51 | |
52 |