Tag Archives: algorithms

Algorithms Group: Literate programming

Algo­rithms group today took a brake from dis­cussing algo­rithms for an aside on cod­ing prac­tices.  Today we focused pri­mar­ily on lit­er­ate pro­gram­ming tools for mak­ing bet­ter doc­u­mented, more read­able code.   We cov­ered: Sweave Google style guide, also see R core-team devel­oper Hadley Wickam’s style guide (mod­i­fied from Google) R cod­ing prac­tices grab-bag: using func­tion­al­ized

Algorithms Group, HMM meets EM

Alisa reviews HMM, EM, and shows us how to com­bine them. The EM ver­sion treats the tran­si­tion prob­a­bil­i­ties (exchang­ing coins) and emis­sion prob­a­bil­i­ties (chance of heads/tails under each coin) as unknowns.  Make a guess, cal­cu­late the blue line from before.  This can be used to cal­cu­late a new guess that will hill climb to the locally

Algorithms group: Hidden Markov Models

Great group dis­cus­sion on Hid­den Markov Mod­els tag-teamed by Yaniv and Alisa.  Walked through the coin flip exam­ple, cre­at­ing the for­ward algo­rithm, and the pos­te­rior decod­ing.  In this case it is assumed model and para­me­ters are known: two coins, known ratios, known rate of swap­ping; goal is to guess which coin is being used in

Monday: Algorithms Discussion Group, EM finished

Fin­ished up the EM algo­rithm today.  Key was get­ting the right func­tion to max­i­mize.  Turns out wikipedia has a very nice write up of this very exam­ple, but in our nota­tion: \[  E_p \log(p f_1) + (1-E_p) \log( (1-p) f_2 )\] Where \(E_p\) comes from the expec­ta­tion step. Jamie has joined us and has set up a

EM Algorithm

Yaniv ran us through our sec­ond ses­sion on EM algo­rithms.  We imple­mented a sim­ple case described in this tuto­r­ial. Code doesn’t reflect the abstrac­tion of the algo­rithm into a proper Expec­ta­tion step and Max­i­miza­tion step.  We attempted this gen­er­al­iza­tion: Missed some­thing in fram­ing this cor­rectly, since the max­i­miza­tion step includes a func­tion that doesn’t depend

Algorithms group: MCMCMC

Dis­cussed \(\text{MC}^3\), the Metrop­o­lis cou­pled Markov Chain Monte Carlo, in Monday’s algo­rithms group meet­ing, just get­ting around to post­ing code.  The MrBayes paper is a good ref­er­ence for this .  Our prac­tice exam­ple needed some debug­ging. I re-wrote a gen­eral pur­pose mcm­cmc func­tion in R to illus­trate the algo­rithm, below.  Recall that it mod­i­fies our

Monday: meetings, notebook

Coop & Moore 270: Species Trees Dis­cussing Bucky paper Approach of BEST and *BEAST (last time): Prior prob­a­bil­ity on gene trees P(G|S), given species trees.  Goal: Pos­te­rior of species trees, Uses a Dirch­let process model for clus­ter­ing genes by topolo­gies.  All genes in a clus­ter agree to share a com­mon topol­ogy.  Com­par­isons to BEST and *BEAST

Algorithms Discussion Group: MCMC

Imple­mented a basic MCMC rou­tine in our lit­tle algo­rithms dis­cus­sion group today, works quite nicely once you remem­ber to use dif­fer­ences of log prob­a­bil­i­ties instead of ratios.  Code and results below.

Algorithms Discussion Group: ABC Continued

Our lit­tle infor­mal ABC group met again today to con­tinue our dis­cus­sion of ABC meth­ods from last week. The updated code is included in the gist below.1 The pos­te­rior dis­tri­b­u­tion from the regres­sion The regres­sion is used to deter­mine the pos­te­rior dis­tri­b­u­tion of the para­me­ter. We want to move each the observed val­ues down along

Monday: ABC Meeting

Yaniv has started an algo­rithms dis­cus­sion group. We just met with a few  stu­dents to dis­cuss imple­ment­ing Approx­i­mate Bayesian Com­put­ing meth­ods from scratch.  Most of us had read and   but also fol­lowed most help­ful dur­ing the ses­sion. This gets us as far as the regres­sion step, Fig­ure 1 of .  This in part dis­tin­guishes