CS166
Chris Pollett
Oct 24, 2012
Problem 7.37 Using the info provided with this problem...
(a). Use equation 7.1 to compute the distance: `d(\A\l\i\c\e, \B\o\b)`, `d(\A\l\i\c\e, \C\h\a\r\l\i\e)`, `d(\B\o\b, \C\h\a\r\l\i\e)`.
(b). Assuming the same statistics apply to the shortened iris codes as to normal-lengthed ones, which of the users U,V,W,X,Y is most likely Alice? Bob? Charlie? None of the above?
Answer. To solve this problem, I wrote the following PHP script to dompute all the distances:
<?php
//php in xampp is 32 bit
$c['alice'][0]= 0xbe439ad5; // high order half
$c['alice'][1]= 0x98ef5147; // low order half
$c['bob'][0] = 0x9c8b7a14;
$c['bob'][1] = 0x25369584;
$c['charlie'][0]=0x88552233;
$c['charlie'][1]=0x6699ccbb;
$c['u'][0] = 0xc975a213;
$c['u'][1] = 0x2e89ceaf;
$c['v'][0] = 0xdb9a8675;
$c['v'][1] = 0x342fec15;
$c['w'][0] = 0xa6039ad5;
$c['w'][1] = 0xf8cfd965;
$c['x'][0] = 0x1dca7a54;
$c['x'][1] = 0x273497cc;
$c['y'][0] = 0xaf8b6c7d;
$c['y'][1] = 0x5e3f0f9a;
foreach($c as $first_pair => $first_iris_code) {
foreach($c as $last_pair => $last_iris_code) {
echo "d($first_pair, $last_pair) = " .
iris_distance($first_iris_code, $last_iris_code)."\n";
}
}
function iris_distance($code1, $code2)
{
$score = 0;
for($k = 0; $k < 2; $k++) {
for($i = 0; $i< 32; $i++) {
if (($code1[$k] & 1) != ($code2[$k] & 1)) {
$score++;
}
$code1[$k] = floor($code1[$k]/2);
$code2[$k] = floor($code2[$k]/2);
}
}
return $score/64;
}
?>
Using this `d(\A\l\i\c\e, \B\o\b) = 0.453125`, `d(\A\l\i\c\e, \C\h\a\r\l\i\e) = 0.609375`, and `d(\B\o\b, \C\h\a\r\l\i\e) = 0.53125`, answering (a). For (b), `d(u, \C\h\a\r\l\i\e) = 0.171875` so is Charlie, `v` had a score bigger than 0.32 in each case so was no one, `d(w, \A\l\i\c\e) = 0.15625` so `w` is alice, `d(x, \B\o\b) = 0.15625` so `x` is Bob, and `y` did not correspond to anyone.