package dr.math.distributions;

import dr.math.UnivariateFunction;

/**
 * @author Marc A. Suchard
 * @author Philippe Lemey
 */
public class MarginalizedAlphaStableDistribution implements Distribution {

    private final double scale;
    private final double alpha;

    public MarginalizedAlphaStableDistribution(double scale, double alpha) {
        this.scale = scale;
        this.alpha = alpha;
    }

    @Override
    public double pdf(double x) {
        return Math.exp(logPdf(x));
    }

    @Override
    public double logPdf(double x) {
        return logPdf(x, scale, alpha);
    }

    @Override
    public double cdf(double x) {
        throw new RuntimeException("Not yet implemented");
    }

    @Override
    public double quantile(double y) {
        throw new RuntimeException("Not yet implemented");
    }

    @Override
    public double mean() {
        throw new RuntimeException("Not yet implemented");
    }

    @Override
    public double variance() {
        throw new RuntimeException("Not yet implemented");
    }

    @Override
    public UnivariateFunction getProbabilityDensityFunction() {
        throw new RuntimeException("Not yet implemented");
    }

    public static double logPdf(double x, double scale, double alpha) {
        return -Math.log(scale) - alpha * Math.abs(x) / scale;
    }

    public static double gradLogPdf(double x, double scale, double alpha) {
        throw new RuntimeException("Not yet implemented");
    }
}

@@ -1297,16 +1297,17 @@
 ) - 
-alpha * 
+Math.pow(
 Math
@@ -1317,24 +1317,32 @@
 s(x) / scale
+, alpha)
 ;%0A    %7D%0A%0A   

fix marginalized alpha-stable distribution