在Matlab中将正态分布划分为相等概率的区域

时间:2022-04-24 00:31:00

Consider a Normal distribution with mean 0 and standard deviation 1. I would like to divide this distribution into 9 regions of equal probability and take a random sample from each region.

考虑具有均值0和标准差1的正态分布。我想将该分布划分为9个具有相等概率的区域,并从每个区域取随机样本。

1 个解决方案

#1


It sounds like you want to find the values that divide the area under the probability distribution function into segments of equal probability. This can be done in matlab by applying the norminv function.

听起来你想找到将概率分布函数下的面积划分为相等概率段的值。这可以通过应用norminv函数在matlab中完成。

In your particular case:

在您的特定情况下:

segmentBounds = norminv(linspace(0,1,10),0,1)

segmentBounds = norminv(linspace(0,1,10),0,1)

Any two adjacent values of segmentBounds now describe the boundaries of segments of the Normal probability distribution function such that each segment contains one ninth of the total probability.

现在,segmentBounds的任何两个相邻值都描述了Normal概率分布函数的段的边界,使得每个段包含总概率的九分之一。

I'm not sure exactly what you mean by taking random numbers from each sample. One approach is to sample from each region by performing rejection sampling. In short, for each region bounded by x0 and x1, draw a sample from y = normrnd(0,1). If x0 < y < x1, keep it. Else discard it and repeat.

我不确定你从每个样本中随机抽取数字到底是什么意思。一种方法是通过执行拒绝采样从每个区域采样。简而言之,对于由x0和x1限定的每个区域,从y = normrnd(0,1)绘制样本。如果x0

It's also possible that you intend to sample from these regions uniformly. To do this you can try rand(1)*(x1-x0) + x0. This will produce problems for the extreme quantiles, however, since the regions extend to +/- infinity.

您也可以统一从这些区域进行采样。为此,您可以尝试rand(1)*(x1-x0)+ x0。然而,这将产生极端分位数的问题,因为区域延伸到+/-无穷大。

#1


It sounds like you want to find the values that divide the area under the probability distribution function into segments of equal probability. This can be done in matlab by applying the norminv function.

听起来你想找到将概率分布函数下的面积划分为相等概率段的值。这可以通过应用norminv函数在matlab中完成。

In your particular case:

在您的特定情况下:

segmentBounds = norminv(linspace(0,1,10),0,1)

segmentBounds = norminv(linspace(0,1,10),0,1)

Any two adjacent values of segmentBounds now describe the boundaries of segments of the Normal probability distribution function such that each segment contains one ninth of the total probability.

现在,segmentBounds的任何两个相邻值都描述了Normal概率分布函数的段的边界,使得每个段包含总概率的九分之一。

I'm not sure exactly what you mean by taking random numbers from each sample. One approach is to sample from each region by performing rejection sampling. In short, for each region bounded by x0 and x1, draw a sample from y = normrnd(0,1). If x0 < y < x1, keep it. Else discard it and repeat.

我不确定你从每个样本中随机抽取数字到底是什么意思。一种方法是通过执行拒绝采样从每个区域采样。简而言之,对于由x0和x1限定的每个区域,从y = normrnd(0,1)绘制样本。如果x0

It's also possible that you intend to sample from these regions uniformly. To do this you can try rand(1)*(x1-x0) + x0. This will produce problems for the extreme quantiles, however, since the regions extend to +/- infinity.

您也可以统一从这些区域进行采样。为此,您可以尝试rand(1)*(x1-x0)+ x0。然而,这将产生极端分位数的问题,因为区域延伸到+/-无穷大。