Skip to content

Instantly share code, notes, and snippets.

@llamerada
llamerada / szaru_sample.py
Created November 12, 2010 06:43
SZaru sample in Python
import random
import szaru
qtl_est = szaru.QuantileEstimatorInt32(11)
lst = range(1001)
random.shuffle(lst)
for i in lst:
qtl_est.add_elem(i)
@llamerada
llamerada / szaru_sample.rb
Created November 12, 2010 06:41
SZaru sample in Ruby
require "szaru"
unq_est = SZaru::UniqueEstimator.new(10)
1000.times do |i|
unq_est.add_elem(i.to_s + "test")
end
puts unq_est.estimate # => 913
@llamerada
llamerada / szaru_sample.cc
Created November 12, 2010 06:37
SZaru sample in C++
#include <iostream>
#include <szaru.h>
using namespace std;
using namespace SZaru;
TopEstimator<int32_t> *topEst = TopEstimator<int32_t>::Create(3);
topEst->AddWeightedElem("abc", 1);
topEst->AddWeightedElem("def", 2);
topEst->AddWeightedElem("ghi", 3);
topEst->AddWeightedElem("def", 4);