Bobs code will be pretty basic, I think one think I’ve learnt is that staying basic is a key to many ABMs. Bob inputs stuff from the web and things about whats happening. Condidtional probability is the probability of an event happening as a result of having observed a different event. A basic way to work out what the conditional probability of something is the number of times Event A and Event B happen together, divided by how many times Event B happens on its own. (A & B) / (B). This is all Bob will do. The code looks something like what IBM have going on here. `<?php` `/**` `* Returns conditional probability of $A given $B and $Data.` `* $Data is an indexed array. Each element of the $Data array ` `* consists of an A measurement and B measurment on a sample ` `* item.` `*/` `function getConditionalProbabilty($A, $B, $Data) {` ` $NumAB = 0;` ` $NumB = 0;` ` $NumData = count($Data);` ` for ($i=0; $i < $NumData; $i++) {` ` if (in_array($B, $Data[$i])) {` ` $NumB++;` ` if (in_array($A, $Data[$i])) {` ` $NumAB++;` ` }` ` }` ` }` ` return $NumAB / $NumB;` `}` `?>` Bob will operate on counts and frequencies. This isn’t good because we want to probability values rather than frequency counts. I haven’t decided if I’ll expand on Bobs intelligence or create a new agent. I need to get the data in first! I’m tied and its Friday. |

Notes >