【发布时间】:2019-08-10 13:39:14
【问题描述】:
假设我有一个连续概率分布,例如,Normal,在支持 A 上。假设有一个 Matlab 代码允许我从这样的分布中抽取随机数,例如,this。
我想构建一个 Matlab 代码,以使用跨越 r 个点的概率质量函数“近似”这种连续概率分布。
这意味着我想写一个Matlab代码来:
(1) 从 A 中选择 r 个点。我们称这些点为 a1,a2,...,ar。这些点将构成新的离散支持。
(2) 在 a1,a2,...,ar 上构造概率质量函数。这个概率质量函数应该“很好地”接近原始的连续概率分布。
您能否提供一个示例来提供帮助? This 是向 Julia 提出的类似问题。
这是我的一些想法。假设感兴趣的连续概率分布是一维的。一种方法可能是:
(1) 从感兴趣的连续概率分布中抽取10^6个随机数,并将它们存储在一个列向量D中。
(2) 假设 r=10。计算 D 的第 10、第 20、...、第 90 分位数。找到落在所获得的 10 个 bin 中的每一个中的中点。将这些中点称为 a1,...,ar。
如何从这里构造概率质量函数? 另外,如何将这个过程推广到多个维度?
使用histcounts 更新:我考虑过使用histcounts。你认为这是一个有效的选择吗?对于许多维度,我可以使用this。
clear
rng default
%(1) Draw P random numbers for standard normal distribution
P=10^6;
X = randn(P,1);
%(2) Apply histcounts
[N,edges] = histcounts(X);
%(3) Construct the new discrete random variable
%(3.1) The support of the discrete random variable is the collection of the mean values of each bin
supp=zeros(size(N,2),1);
for j=2:size(N,2)+1
supp(j-1)=(edges(j)-edges(j-1))/2+edges(j-1);
end
%(3.2) The probability mass function of the discrete random variable is the
%number of X within each bin divided by P
pmass=N/P;
%(4) Check if the approximation is OK
%(4.1) Find the CDF of the discrete random variable
CDF_discrete=zeros(size(N,2),1);
for h=2:size(N,2)+1
CDF_discrete(h-1)=sum(X<=edges(h))/P;
end
%(4.2) Plot empirical CDF of the original random variable and CDF_discrete
ecdf(X)
hold on
scatter(supp, CDF_discrete)
【问题讨论】:
-
概率质量函数是一个函数,它给出了一个离散随机变量恰好等于某个值的概率 [en.wikipedia.org/wiki/Probability_mass_function].但也许您所追求的是使用(例如)10 个点的“离散支持”对 连续 概率分布进行建模。做到这一点的最佳方法取决于您打算如何在这些点之间进行插值,例如线性插值、三次插值或支持向量机?大多数插值方法使用支持向量网格推广到更高维度。
-
谢谢。您能否举例说明您建议的任何方法(例如线性插值)如何满足我的需求?谢谢。
-
另外,最后我想要一个概率质量函数(总和为 1)。谢谢
-
感谢大家。我不是专家,如果你能添加一个例子会很有帮助,例如,假设我想使用离散化支持对标准正态分布进行建模。
标签: matlab probability probability-density continuous