【问题标题】:Matlab and normal realizationsMatlab和正常的实现
【发布时间】:2014-06-19 14:15:58
【问题描述】:

我已经写了这段代码:。

N=10000; % number of experiments
o= 1000+randn(1,N)*sqrt(10^4); % random normal distribution with mean 1000 and variance 10^4
b=700:50:1300; % specify the number of bins (possible values of the realizations)
prob=hist(o,b)/N %create ad histogram

X=[700:50:1300] **

现在,我如何创建一个包含 b 和 prob 值的矩阵? 换句话说,我想要一个这样的矩阵:

矩阵=[ X(i) 的值; X(i) 值处的概率关联]

es: 矩阵=[... X(i)=850... ; ...概率(X(i)=850)..]

非常感谢! ;)

【问题讨论】:

  • 与任何单个值相关的概率为0。你应该重新考虑你想要什么
  • 它不是 0。如果您运行脚本,您将获得概率。我唯一的问题是将它保存在矩阵中。
  • is 0。您的脚本给出了 intervals 的概率
  • 我已经编辑了帖子。现在更清楚了?
  • 恐怕不行。我坚持:value 的概率为 0。interval of values 的概率更有意义。看我的回答;这就是你想要的吗?

标签: matlab matrix histogram probability normal-distribution


【解决方案1】:

我认为您想要计算直方图的间隔的概率:

N = 100000; %// number of experiments
b = 700:50:1300; %// bin centers
mu = 1000; %// mean of distribution
sigma = 100; %// standard deviation of distribution

delta = (b(2)-b(1))/2; %// compute bin half-width
pb = normcdf(b+delta,mu,sigma)-normcdf(b-delta,mu,sigma); %// compute probability

检查:

o = mu + sigma*randn(1,N);
hist(o, b)
hold on
plot(b, N*pb, 'r', 'linewidth', 2)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-01
    • 2021-09-05
    • 2020-03-22
    • 2022-11-25
    • 2017-08-01
    • 2015-05-20
    • 1970-01-01
    • 2013-02-05
    相关资源
    最近更新 更多