import mir.math.common: log; import mir.test: shouldApprox; laplaceLPDF(-2.0).shouldApprox == log(0.06766764); laplaceLPDF(-1.0).shouldApprox == log(0.1839397); laplaceLPDF(-0.5).shouldApprox == log(0.3032653); laplaceLPDF(0.0).shouldApprox == log(0.5); laplaceLPDF(0.5).shouldApprox == log(0.3032653); laplaceLPDF(1.0).shouldApprox == log(0.1839397); laplaceLPDF(2.0).shouldApprox == log(0.06766764); // Can also provide location/scale parameters laplaceLPDF(-1.0, 2.0, 3.0).shouldApprox == log(0.06131324); laplaceLPDF(1.0, 2.0, 3.0).shouldApprox == log(0.1194219); laplaceLPDF(4.0, 2.0, 3.0).shouldApprox == log(0.08556952);
Ditto, with location and scale parameters (by standardizing x).