Return-Path: X-Original-To: apmail-mahout-dev-archive@www.apache.org Delivered-To: apmail-mahout-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CBA94A16 for ; Sat, 21 May 2011 04:15:03 +0000 (UTC) Received: (qmail 28101 invoked by uid 500); 21 May 2011 04:15:03 -0000 Delivered-To: apmail-mahout-dev-archive@mahout.apache.org Received: (qmail 28066 invoked by uid 500); 21 May 2011 04:15:03 -0000 Mailing-List: contact dev-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list dev@mahout.apache.org Received: (qmail 28058 invoked by uid 99); 21 May 2011 04:15:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 May 2011 04:15:02 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of goksron@gmail.com designates 209.85.216.42 as permitted sender) Received: from [209.85.216.42] (HELO mail-qw0-f42.google.com) (209.85.216.42) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 May 2011 04:14:56 +0000 Received: by qwi4 with SMTP id 4so5040807qwi.1 for ; Fri, 20 May 2011 21:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=HLWY2f2E5gs4whqWqwAmb4SGJqa9EPpgYfEofrcXbig=; b=AspDYiU7lf6MJp1sYx+UeTuJXdyKhFFGzzbkv5MyyIyyyYG5T2uk7ng4VnyP4FL5PO Mx08tNynSHyFxQvzzE5gtnm6un/ZvPfjwpbSilJMfDZKHcbd3Cu7LKPMCA7bVk0h/7fm Wu5E1m8dmR9570agvwOOZthPlRfUCgvuJQYrs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=JmaXFL+/waSyM4ZSaZjsykjD3e30io3md5GK5bQfjfbYFkizUU8E/dBCD3Aa3YraWA xbx7kUNlVG91S85m07I0s1aWBiDhQ7K8RmhRDlSobWpiMWAWcrpFMLb0+nQZ3F3XO0vf hk9ZrNBovdxVz33AC6y3xNSC2XVwOTtM7OvWA= MIME-Version: 1.0 Received: by 10.229.69.213 with SMTP id a21mr221705qcj.222.1305951275424; Fri, 20 May 2011 21:14:35 -0700 (PDT) Received: by 10.229.226.1 with HTTP; Fri, 20 May 2011 21:14:35 -0700 (PDT) In-Reply-To: References: <888004344.23670.1304573943158.JavaMail.tomcat@hel.zones.apache.org> <672498739.32704.1305944747359.JavaMail.tomcat@hel.zones.apache.org> Date: Fri, 20 May 2011 21:14:35 -0700 Message-ID: Subject: Re: [jira] [Commented] (MAHOUT-687) Random generator objects- slight refactor From: Lance Norskog To: dev@mahout.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Right! Ok. Yes, that makes a lot more sense. I'm parking my random vector/matrix stuff because it's clear (to me at least) that Vector&Matrix need some revamping. But still, how should a random based on MurmurHash work? Lance On Fri, May 20, 2011 at 7:29 PM, Ted Dunning wrote: > No. =C2=A0I was referring to the specific use of random number generators= to > generate an ephemeral random matrix. =C2=A0I prefer to hash the element l= ocation > in order to generate the element value than to use a random number genera= tor > seeded by the element location. =C2=A0These are formally equivalent but > practically quite different since hash functions are often designed with > fast startup and PRNG's are often designed without much regard to startup= or > reseeding cost. =C2=A0MersenneTwister in particular is a very bad generat= or with > respect to the cost of reseeding. =C2=A0Murmurhash is a very good example= of a > lean hash function. > > On Fri, May 20, 2011 at 7:25 PM, Lance Norskog (JIRA) wr= ote: > >> >> Ted, you mentioned wanting a MurmurHash Random class. Is this what you >> envisioned? (It is not finished code; see below). >> >> {code} >> public class MurmurHashRandom extends Random { >> =C2=A0private long murmurSeed; >> =C2=A0private final ByteBuffer buf; >> >> =C2=A0public MurmurHashRandom() { >> =C2=A0 =C2=A0this(0); >> =C2=A0} >> >> =C2=A0public MurmurHashRandom(int seed) { >> =C2=A0 =C2=A0SeedGenerator gen =3D new FastRandomSeedGenerator(); >> =C2=A0 =C2=A0byte[] bits =3D RandomUtils.longSeedtoBytes(gen.generateSee= d()); >> =C2=A0 =C2=A0buf =3D ByteBuffer.wrap(bits); >> =C2=A0 =C2=A0this.murmurSeed =3D MurmurHash.hash64A(bits, seed); >> =C2=A0} >> >> =C2=A0@Override >> =C2=A0public long nextLong() { >> =C2=A0 =C2=A0long oldSeed =3D murmurSeed; >> =C2=A0 =C2=A0murmurSeed =3D MurmurHash.hash64A(buf, (int) murmurSeed); >> =C2=A0 =C2=A0return oldSeed; >> =C2=A0} >> >> {code} >> >> > --=20 Lance Norskog goksron@gmail.com