Discretizing the probability distribution

조회 수: 2 (최근 30일)
alpedhuez
alpedhuez 2020년 7월 26일
답변: Bruno Luong 2020년 7월 26일
I have a probability distribution f on [0,1]. I want to discretize f on (0,0.1,0.2,...1). I see
"What you could do instead, in order to approximate it to a discrete probability space, is to define some points (x_1, x_2, ..., x_n), and let their discrete probabilities be the integral of some range of the PDF (from your continuous probability distribution), that is P(x_1) = P(X \in (-infty, x_1_end)), P(x_2) = P(X \in (x_1_end, x_2_end)), ..., P(x_n) = P(X \in (x_(n-1)_end, +infty))"
Is there any implementation of this idea?
  댓글 수: 4
John D'Errico
John D'Errico 2020년 7월 26일
편집: John D'Errico 2020년 7월 26일
And what do you think your question asked? That is, it seems to be to find the points x1,x2,...
You don't recognize what was said there as locating the corresponding quantiles of that distribution?
If all you want to do is to find the probbilities for a fixed set of x_i, then all you need to do is compute the integral under the PDF, and this is given directly by the CDF. In any event, this is fairly easy to do.
alpedhuez
alpedhuez 2020년 7월 26일
(x_1, x_2, ..., x_n), are the points in the domain of PDF.

댓글을 달려면 로그인하십시오.

채택된 답변

Bruno Luong
Bruno Luong 2020년 7월 26일
To generate 1D random variable with a prescribed continuous PDF, one need 2 things:
  1. able to integrate pdf (called cdf)
  2. able to invert it
If you know how to do 1 and 2, then problem solves.
If you know to do 1 and not 2, then you can use INTERPOLATION in place invertion, after selecting a set of intervals that cover the domain. I think using 'pchip' is the best since it preserves monotonic and also more accurate than the default 'LINEAR'.
If you don't know to do 1 and 2, but knowing evaluate PDF, then using cumulative sum, trapz rule, simpson rule to replace the continuous CDF by discrete sum, then do the interpolation as above.
In this thread I post some code for the later case. Feel free to modify the code, for example experiment with other interpolation method ('pchip') and integration method (replace cumsum with appropriate higher integration rule).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Special Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by