乘客等候时间分布Matlab

Waiting time distribution of passengers Matlab

我知道我的问题可能很基本,但我已经被屏蔽了 2 天...我需要在 Matlab 中计算乘客的等待时间分布,比如 this one。我有以下数据:

  1. WT,长度为 L
  2. 的等待时间向量
  3. PAX,经历等待时间的乘客向量,长度也是L。 PAX(i) 经历了等待时间 WT(i),例如3 名乘客经历了 1.2 分钟。 乘客均匀分布

我手动看到了如何做到这一点(为 WT 创建箱子,将相似的等待时间分组,并推断出乘客必须等待这个特定等待时间的概率)但是当我在 Matlab 中尝试时,我被阻止了。 编辑:我应该使用 histcounts 吗?

非常感谢,

安妮

像这样的事情怎么样:

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.

另一个选项:

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)