001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.rng.sampling.distribution;
018
019/**
020 * Interface for a continuous distribution that can be sampled using
021 * the <a href="https://en.wikipedia.org/wiki/Inverse_transform_sampling">
022 * inversion method</a>.
023 *
024 * @since 1.0
025 */
026public interface ContinuousInverseCumulativeProbabilityFunction {
027    /**
028     * Computes the quantile function of the distribution.
029     * For a random variable {@code X} distributed according to this distribution,
030     * the returned value is
031     * <ul>
032     *  <li>\( \inf_{x \in \mathcal{R}} P(X \le x) \ge p \) for \( 0 \lt p \le 1 \)</li>
033     *  <li>\( \inf_{x \in \mathcal{R}} P(X \le x) \gt 0 \) for \( p = 0 \)</li>
034     * </ul>
035     *
036     * @param p Cumulative probability.
037     * @return the smallest {@code p}-quantile of the distribution
038     * (largest 0-quantile for {@code p = 0}).
039     * @throws IllegalArgumentException if {@code p < 0} or {@code p > 1}.
040     */
041    double inverseCumulativeProbability(double p);
042}