Mercurial > hg > jslab
comparison src/samer/maths/random/SparseMixture.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 /* | |
2 * Copyright (c) 2000, Samer Abdallah, King's College London. | |
3 * All rights reserved. | |
4 * | |
5 * This software is provided AS iS and WITHOUT ANY WARRANTY; | |
6 * without even the implied warranty of MERCHANTABILITY or | |
7 * FITNESS FOR A PARTICULAR PURPOSE. | |
8 */ | |
9 | |
10 package samer.maths.random; | |
11 import samer.maths.*; | |
12 import samer.core.types.*; | |
13 | |
14 public class SparseMixture extends BaseRandom | |
15 { | |
16 VDouble p = new VDouble("p",0.5); | |
17 Generator g1; | |
18 | |
19 public void dispose() { g1.dispose(); p.dispose(); } | |
20 public double next() { return (rnd.nextDouble()<p.value) ? 0 : g1.next(); } | |
21 | |
22 public SparseMixture(Generator g1) { this.g1=g1; } | |
23 public String toString() { return "Sparsified "+g1; } | |
24 } |