Mercurial > hg > silvet
comparison yeti/silvet.yeti @ 25:80f02ff5d37a
I think that previous normalisation was wrong!
author | Chris Cannam |
---|---|
date | Mon, 31 Mar 2014 15:41:15 +0100 |
parents | 0e8ee830b5ee |
children | fbc4011c7693 |
comparison
equal
deleted
inserted
replaced
24:0e8ee830b5ee | 25:80f02ff5d37a |
---|---|
68 | 68 |
69 \() (plot.plot [ Caption "Source frequency distribution", Vector col ]); | 69 \() (plot.plot [ Caption "Source frequency distribution", Vector col ]); |
70 | 70 |
71 \() (plot.plot [ Caption "Source distribution beforehand", Grid em1data.sources]); | 71 \() (plot.plot [ Caption "Source distribution beforehand", Grid em1data.sources]); |
72 | 72 |
73 normalise v = | |
74 (s = vec.sum v; | |
75 if s > 0 then vec.divideBy s v | |
76 else v | |
77 fi); | |
78 | |
73 oneIteration em1data col n = | 79 oneIteration em1data col n = |
74 (q = em1.performExpectation em1data col; | 80 ({ estimate, q } = em1.performExpectation em1data col; |
75 // \() (plot.plot [ Caption "Frequency distribution and output of E-step for iteration \(n)", Vector col, Vector q ]); | 81 // \() (plot.plot [ Caption "Frequency distribution and output of E-step for iteration \(n)", Vector col, Vector q ]); |
76 newdata = em1.performMaximisation em1data col q; | 82 newdata = em1.performMaximisation em1data col q; |
77 if (n % 6 == 0) then | 83 if (n % 6 == 0) then |
78 \() (plot.plot [ Caption "Pitch distribution before and after M-step update for iteration \(n)", Vector (em1data.pitches), Vector (newdata.pitches) ]); | 84 \() (plot.plot [ Caption "Pitch distribution before and after M-step update for iteration \(n)", Vector (em1data.pitches), Vector (newdata.pitches) ]); |
79 \() (plot.plot [ Caption "Source distribution after M-step update for iteration \(n)", Grid newdata.sources ]); | 85 \() (plot.plot [ Caption "Source distribution after M-step update for iteration \(n)", Grid newdata.sources ]); |
86 \() (plot.plot [ Caption "Q function for E-step iteration \(n)", Vector q ]); | |
87 \() (plot.plot [ Caption "Estimate from E-step iteration \(n) against original source distribution, and difference between them", Vector estimate, Vector (normalise col), Vector (vec.subtract estimate (normalise col)) ]); | |
80 fi; | 88 fi; |
81 newdata); | 89 newdata); |
82 | 90 |
83 iterations = 12; | 91 iterations = 12; |
84 | 92 |
121 fi; | 129 fi; |
122 done; | 130 done; |
123 | 131 |
124 println "Instruments: \(map do i: (d.instruments[i]) done instruments)"; | 132 println "Instruments: \(map do i: (d.instruments[i]) done instruments)"; |
125 | 133 |
126 normalise v = | |
127 (s = vec.sum v; | |
128 if s > 0 then vec.divideBy s v | |
129 else v | |
130 fi); | |
131 | |
132 if not (empty? sounding) then | 134 if not (empty? sounding) then |
133 p = head sounding; | 135 p = head sounding; |
134 i = head instruments; | 136 i = head instruments; |
135 w = mat.getColumn p d.templates[i]; | 137 w = mat.getColumn p d.templates[i]; |
136 \() (plot.plot [ Vector w, Vector (normalise col), Caption "Template for instrument \(d.instruments[i]), pitch \(p), against normalised source distribution" ]); | 138 \() (plot.plot [ Vector w, Vector (normalise col), Caption "Template for instrument \(d.instruments[i]), pitch \(p), against normalised source distribution" ]); |