Mercurial > hg > jslab
view src/samer/maths/random/BoundedHyperbolic.java @ 5:b67a33c44de7
Remove some crap, etc
author | samer |
---|---|
date | Fri, 05 Apr 2019 21:34:25 +0100 |
parents | bf79fb79ee13 |
children |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.maths.random; import samer.core.types.*; import java.util.*; /* * Hyperbolic distribution: power law with exponent 1. * Integral of pdf diverges in both directions, so we * need both upper and lower cut-offs. */ public class BoundedHyperbolic extends BaseRandom implements Observer { VDouble min = new VDouble("min",1); VDouble max = new VDouble("max",2); double a, b; public void dispose() { min.dispose(); max.dispose(); } public double next() { return b*Math.exp(a*rnd.nextDouble()); } public BoundedHyperbolic( double min, double max) { this(); this.min.value = min; this.min.changed(); this.max.value = max; this.max.changed(); } public BoundedHyperbolic() { min.addObserver(this); max.addObserver(this); update(null,null); } public void update(Observable o, Object oo) { a=Math.log(min.value/max.value); b=max.value; } }