The pdf for the multivariate normal distribution in MATLAB is mvnpdf(...). What about the case where multiple variables are uniformly distributed: Is there a function to describe their joint distribution analogous to the multivariate normal distribution? If there is no such function, is there a trick to handle this case?
The simplest way how several variables can be uniformly distributed is if they are mutually independent; in that case you simply have a uniform distribution over the hypercube in the space spanned by the variables. In order to get samples from this distribution, you just separately generate samples for each of the variables.
The point where a "trick" might be necessary is if you have dependencies between the variables even though the marginal distribution for each of them is still uniform. In this case you have to describe the dependency structure, and I'm not aware of any standard way to do this (the way dependencies between normally distributed variables are described by a correlation matrix).
Of course such distributions exist: For two dimensions, one possibility would be to have a joint distribution that looks like a solution to the "eight rooks" problem:
Another one actually derives from the introductory Matlab example, the magic square:
Both of these examples are discrete distributions, but can be produced at arbitrary granularity, or simply interpreted as piecewise constant continuous distributions.
As you can see there are many possibilities for a multivariate distribution each of whose marginal distributions are uniform. The question you have to answer for yourself is what kind of dependencies, if any, you are interested in?
If I'm understanding the question properly, we want to calculate the pdf of a multivariate uniform distribution. By definition, the pdf is constant for all values in the support the distribution. Thus to calculate the pdf all that is required is to calculate the norming constant, which is given by the inverse of the integral of the support. That is to say, the pdf is given by
f(x) = 1 / integral(A)
where A is the support set, and x is an element in A. If an analytic solution to integral(A) is not available, then a numerical integrator can be employed.
Related
Consider a concrete example, I have three different uniform distributions, i.e., x~U(-40,20),y~(-20,40),z~(-20,20).
So I can calculate E[x+], E[x-], E[y+],E[y-],E[z+],E[z-], where x+ denotes max{0,x}, x- denotes min{0,x}.
Based on the uniform distribution, the moment matrix is calculated by
E[(x+,x-,y+,y-,z+,z-)^T(x+,x-,y+,y-,z+,z-)]. At the same time, I restrict E[x+x-]=0 in the moment matrix.
For simplicity, assume x,y,z are i.i.d
My question is how to randomly generate samples (x+,x-,y+,y-,z+,z-) under my setting given the first-two moment in matlab or R?
I have searched a lot and found no method existed to solve the problem I am facing.
Appreciate for all of your help or suggestion on this look-simple question.
Relevant link for generate multivariate uniform distribution is referred to : http://comisef.wikidot.com/tutorial:correlateduniformvariates
But it cannot solve my problem because it only considers all variates following the same specific uniform distribution.
What are some simple and efficient ways to encode a probability distribution as a chromosome for a genetic/evolutionary algorithm?
It highly depends on the nature of the probability distribution you have in hand. As you know, a probability distribution is a mathematical function. Therefore, the properties of this function govern the representation of the probability distribution as a chromosome. For example, do you have a discrete probability distribution (which is encoded by a discrete list of the probabilities of the outcomes like tossing a coin) or a continuous probability distribution (which is applicable when the set of possible outcomes can take on values in a continuous range like the temperature on a given day).
As a simple instance, consider that you want to encode Normal distribution which is an important distribution in probability theory. This distrubution can be encoded as a two-dimensional chromosome in which the first dimension is the mean (Mu) and variance (Sigma^2). You can then calculate the probability using these two parameters. For other continuous probability distribution like Cauchy, you can follow the similar way.
Is randn() in Matlab actually using an inverse normal distribution to generate the random numbers from normal distributions?
This manual page says:
NormalTransform: Transformation algorithm used by randn(s, ...) to
generate normal pseudorandom values. Possible values are 'Ziggurat',
'Polar', or 'Inversion'.
You specifically asked about inversion, so I'm assuming you're already familiar with it. Here are links in case you want to know more about the Ziggurat or polar methods.
Is it possible to define your own probability density function in MATLAB or Octave and use it
for generating random numbers?
MATLAB and Octave have default functions like rand, randn built in to draw points at random from a uniform, or normal distributions but there seems to be no documentation of how to define my very own proability density function.
Sampling from an arbitrary random distribution is not always trivial. For well known distributions there are tricks to implement them and most of them are implemented in stats toolbox as Oli said.
If your distribution of interest is of difficult form, there are many sampling algorithms that may help you, such as, rejection sampling, slice sampling, Metropolis–Hastings algorithm.
If your distribution is discrete, or can be approximated by a discrete distribution fairly well, then you can just do multinomial sampling using randsamp.
If you have the stats toolbox, you can use random(), as it has a lot of useful PDFs built-in.
I've had to do that a few times recently, and it's not exactly an easy thing to accomplish. My favorite technique was to use Inverse transform sampling.
The idea is quite simple:
create a cdf
use a uniform random number generator.
identify the RV that maps to your cdf value.
This might be a silly question! I have a array P which represents the probability distribution of some data e.g. [0;0.3;0.7] How can I determine the type or class of discrete probability distribution of P? The original data is unavailable to me.
dfittool or fitdist requires me to give the data as input, while I already have its probability distribution. Any ideas?
You probably might have seen different probability distributions during lecture or your reading. All you have to do is plotting the given distribution against the candidates. As the distributions itself are parametrized, curve fitting or trial end error come into play. The distribution with the least error, best fit, might be the one you are looking for.
It is not possible to find out a priori what kind of distribution some data (especially with as low n as in your example) is coming from.
If you have an idea of the process that generated your data, you might be able to get an idea of which distributions to test. Maybe your data comes from the family of gamma distributions, maybe your data comes from the family of Weibull distributions etc. Then, you can fit these general distributions and see whether they are likely to simplify to a more common distribution.
For a visual representation of how well your data could approximate a certain distribution, you can use PROBPLOT.
Once you have identified possible distributions, you can fit them to the data and use the Bayesian Information Criterion (BIC) to compare which fit describes the data best. Note that unless you have huge numbers of noise-free data, it is impossible to tell which fit is correct if you have several possible distributions with comparatively low BIC.