我知道我的问题可能非常基本,但我已被封锁了2天......我需要在Matlab中计算乘客的等待时间分布,如 this one。我有以下数据:
手动我看到怎么做(为WT创建垃圾箱,将类似的等待时间分组,并推断出乘客不得不等待这个特定等待时间的概率),但是当我在Matlab中尝试时,我被阻止了。 编辑:我应该使用histcounts吗?
非常感谢,
安
答案 0 :(得分:1)
如下:
histogram(repelem(WT,PAX));
说明:
repelem(WT,PAX) %make a vector where each element WT(i) appears PAX(i) times
histogram(repelem(WT,PAX)) %plot this vector as a histogram
示例:
WT = [1, 1.4, 13, 6];
PAX = [3, 2, 1, 2];
repelem(WT,PAX) = [1, 1, 1, 1.4, 1.4, 13, 6, 6];
%Can't plot this histogram right now as I don't have a license at this machine, but I will edit one in later.
答案 1 :(得分:0)
另一种选择:
R = normrnd(10,3,100,1); %data sample (= PAX in your case)
%calculate the mu and sigma
mu = mean(R);
sigma = std(R);
%creation of the model (assuming that you have normally distributed data)
x = mu-5*sigma:0.1:mu+5*sigma
y = (1/(sigma*sqrt(2*pi)))*exp((-(x-mu).^2/(2*sigma^2))) %the normal distribution formula
%plot the model
plot(x,y)