Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:4267208
Created Dec 12, 2012

What would you like to do?
Скрипт для эмуляции модели линейного счетчика
import scala.util._
import scala.collection.immutable._
val r = new Random()
def calculateLoadFactor(m:Int, n:Int) = (1 to n)
.map { _ => BitSet(r.nextInt(m) + 1) }
.foldLeft(BitSet()) { _ | _ }
.size.toFloat / m
(5000 to 100000 by 5000)
.map(i => (i, (1 to 10).map(_ => calculateLoadFactor(10000, i)).sum.toFloat / 10))
.foreach(i => println (i._1 + "\t" + i._2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment