samer@0: /* samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.functions; samer@0: import samer.maths.*; samer@0: samer@0: /** samer@0: Sparsified Laplacian, v1 samer@0: Log prior for an laplacian distribution with samer@0: an extra mass at zero, eg a mixture of a laplacian samer@0: with another much narrower laplacian. The log prior is samer@0: basically an abs function with with a extra-deep pit at samer@0: zero. samer@0: Paramters control the width and depth of the pit. samer@0: */ samer@0: samer@0: public class BiLaplacian extends Function samer@0: { samer@0: double width=1, A=1, slope=2; samer@0: samer@0: public void setWidth(double b) { width=b; slope=(width+A)/width; } samer@0: public void setStrength(double a) { A=a; slope=(width+A)/width; } samer@0: public double getJump() { return slope; } samer@0: samer@0: public String format(String t) { return "BiLaplace("+t+")"; } samer@0: samer@0: public final double apply(double t) { samer@0: t = Math.abs(t); samer@0: if (t0) { samer@0: if (t-width) return -slope; samer@0: else return -1; samer@0: } else return 0; samer@0: } samer@0: }; samer@0: } samer@0: } samer@0: