package com.imsl.test.example.stat.distributions; import com.imsl.math.PrintMatrix; import com.imsl.math.PrintMatrixFormat; import com.imsl.stat.distributions.ParetoPD; import java.text.DecimalFormat; /** *
* Evaluates the Pareto probability distribution.
** This example evaluates the Pareto density, gradient, and hessian for a small * sample of data.
* * @see Code * @see Output */ public class ParetoPDEx1 { public static void main(String[] args) { double[] x = {1, 2, 7, 20}; ParetoPD ppd = new ParetoPD(); double[] values = new double[x.length]; for (int i = 0; i < x.length; i++) { values[i] = ppd.pdf(x[i], 1.0, 1.0); } PrintMatrixFormat pmf = new PrintMatrixFormat(); pmf.setNumberFormat(new DecimalFormat("0.00000000")); PrintMatrix pm = new PrintMatrix("Pareto(1.0,1.0) pdf values at x="); pm.print(pmf, x); pm.setTitle("f(x;1.0,1.0)="); pm.print(pmf, values); double[] gradient = ppd.getPDFGradientApproximation(x[2], 1.0, 1.0); String title = String.format("Gradient of f(x;1.0,1.0) at x= %1.8f", x[2]); pm.setTitle(title); pm.print(pmf, gradient); double[][] hessian = ppd.getPDFHessianApproximation(x[2], 1.0, 1.0); title = String.format("Hessian of f(x;1.0,1.0) at x= %1.8f", x[2]); pm.setTitle(title); pm.print(pmf, hessian); } }