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.math3.distribution;
018
019import org.apache.commons.math3.exception.NotStrictlyPositiveException;
020
021/**
022 * Base interface for multivariate distributions on the reals.
023 *
024 * This is based largely on the RealDistribution interface, but cumulative
025 * distribution functions are not required because they are often quite
026 * difficult to compute for multivariate distributions.
027 *
028 * @since 3.1
029 */
030public interface MultivariateRealDistribution {
031    /**
032     * Returns the probability density function (PDF) of this distribution
033     * evaluated at the specified point {@code x}. In general, the PDF is the
034     * derivative of the cumulative distribution function. If the derivative
035     * does not exist at {@code x}, then an appropriate replacement should be
036     * returned, e.g. {@code Double.POSITIVE_INFINITY}, {@code Double.NaN}, or
037     * the limit inferior or limit superior of the difference quotient.
038     *
039     * @param x Point at which the PDF is evaluated.
040     * @return the value of the probability density function at point {@code x}.
041     */
042    double density(double[] x);
043
044    /**
045     * Reseeds the random generator used to generate samples.
046     *
047     * @param seed Seed with which to initialize the random number generator.
048     */
049    void reseedRandomGenerator(long seed);
050
051    /**
052     * Gets the number of random variables of the distribution.
053     * It is the size of the array returned by the {@link #sample() sample}
054     * method.
055     *
056     * @return the number of variables.
057     */
058    int getDimension();
059
060    /**
061     * Generates a random value vector sampled from this distribution.
062     *
063     * @return a random value vector.
064     */
065    double[] sample();
066
067    /**
068     * Generates a list of a random value vectors from the distribution.
069     *
070     * @param sampleSize the number of random vectors to generate.
071     * @return an array representing the random samples.
072     * @throws org.apache.commons.math3.exception.NotStrictlyPositiveException
073     * if {@code sampleSize} is not positive.
074     *
075     * @see #sample()
076     */
077    double[][] sample(int sampleSize) throws NotStrictlyPositiveException;
078}