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 */ 017 package org.apache.commons.math3.distribution; 018 019 import 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 * @version $Id: MultivariateRealDistribution.java 1416643 2012-12-03 19:37:14Z tn $ 029 * @since 3.1 030 */ 031 public interface MultivariateRealDistribution { 032 /** 033 * Returns the probability density function (PDF) of this distribution 034 * evaluated at the specified point {@code x}. In general, the PDF is the 035 * derivative of the cumulative distribution function. If the derivative 036 * does not exist at {@code x}, then an appropriate replacement should be 037 * returned, e.g. {@code Double.POSITIVE_INFINITY}, {@code Double.NaN}, or 038 * the limit inferior or limit superior of the difference quotient. 039 * 040 * @param x Point at which the PDF is evaluated. 041 * @return the value of the probability density function at point {@code x}. 042 */ 043 double density(double[] x); 044 045 /** 046 * Reseeds the random generator used to generate samples. 047 * 048 * @param seed Seed with which to initialize the random number generator. 049 */ 050 void reseedRandomGenerator(long seed); 051 052 /** 053 * Gets the number of random variables of the distribution. 054 * It is the size of the array returned by the {@link #sample() sample} 055 * method. 056 * 057 * @return the number of variables. 058 */ 059 int getDimension(); 060 061 /** 062 * Generates a random value vector sampled from this distribution. 063 * 064 * @return a random value vector. 065 */ 066 double[] sample(); 067 068 /** 069 * Generates a list of a random value vectors from the distribution. 070 * 071 * @param sampleSize the number of random vectors to generate. 072 * @return an array representing the random samples. 073 * @throws org.apache.commons.math3.exception.NotStrictlyPositiveException 074 * if {@code sampleSize} is not positive. 075 * 076 * @see #sample() 077 */ 078 double[][] sample(int sampleSize) throws NotStrictlyPositiveException; 079 }