-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joe Green
committed
Jul 10, 2014
1 parent
a759e86
commit 691ee1a
Showing
3 changed files
with
80 additions
and
22 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
include __DIR__ . '/../vendor/autoload.php'; | ||
include __DIR__ . '/randomGenerator.php'; | ||
|
||
// adjusted so the union is almost the size of the hash k | ||
$set1 = randomSet(110000); | ||
|
||
$set2 = randomSet(100000); | ||
|
||
$set3 = randomSet(120000); | ||
|
||
echo "Number of words in set 1: " . count($set1) . "\n"; | ||
|
||
echo "Number of words in set 2: " . count($set2) . "\n"; | ||
|
||
echo "Number of words in set 3: " . count($set3) . "\n"; | ||
|
||
|
||
echo "------\n"; | ||
|
||
echo "Cardinailiy of set 1: " . cardinality($set1) . "\n"; | ||
|
||
echo "Cardinailiy of set 2: " . cardinality($set2) . "\n"; | ||
|
||
echo "Cardinailiy of set 3: " . cardinality($set3) . "\n"; | ||
|
||
$intersection = array_intersect($set1, $set2, $set3); | ||
|
||
$union = array_merge($set1, $set2, $set3); | ||
|
||
$intersectionCount = cardinality($intersection); | ||
|
||
echo "Cardinailiy of union: " . cardinality($union) . "\n"; | ||
|
||
echo "Cardinailiy of intersection: " . $intersectionCount . "\n"; | ||
|
||
echo "------\nLogLog\n"; | ||
|
||
$log_logs = array(); | ||
|
||
foreach(array($set1, $set2, $set3) as $i => $set) | ||
{ | ||
$log_log = new HyperLogLog\MinHash(); | ||
|
||
foreach ($set as $word) { | ||
$log_log->add($word); | ||
} | ||
|
||
$log_logs[] = $log_log; | ||
|
||
echo "Added set " . ($i + 1) . "\n"; | ||
} | ||
|
||
$count = \HyperLogLog\Utils\MinHashIntersector::count($log_logs); | ||
|
||
echo "intersection complete\n"; | ||
|
||
echo $count . "\n" . 'error: ' . number_format(($count - $intersectionCount) / ($intersectionCount / 100.0), 3) . '%' . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters