![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184750/image.jpeg)
How do I average over a number of Histograms?
17 次查看(过去 30 天)
显示 更早的评论
So, I have 100 histogram plots each for different time instant. To analyze the system, I need a histogram plot which is the average of all these plots. How do I do it? I don't want to do it by image processing and all that. Can I do something like generating the histograms with equal number of bins and add the frequencies and then do the average and re-plot the average histogram. But, the problem will be in the histograms of the plots for the different instants, the range might be different. Please help. Thank you.
2 个评论
John BG
2017-6-8
编辑:John BG
2017-6-8
Hi Arghadwip Paul
In general, one can average partial histograms (the different times you mention) when the stochastic process is ergodic.
This happens if the average value doesn't change throughout each sample, and is not null.
From
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/184750/image.jpeg)
So, why don't you start taking small enough time windows and let us know?
John BG
采纳的回答
Walter Roberson
2017-6-7
Do not histogram with an equal number of bins: histogram with consistent edges to the bins. Then you can just put all the results together and mean() as appropriate.
In the below example, numedges-1 and edges(1:end-1) relates to the fact that the number of bins produced by histcounts is one fewer than the number of edges, because the final edge marks the end of the range.
num_datasets = 100;
edges = sort(rand(1, 14) * 5);
numedges = length(edges);
counts = zeros(numedges-1, num_datasets);
for dataset_idx = 1 : 100
counts(:, dataset_idx) = histcounts( datasets{dataset_idx}, edges );
end
avg_counts = mean(counts);
bar(edges(1:end-1), avg_counts)
4 个评论
更多回答(1 个)
Steven Lord
2017-6-7
Generate each set of bin counts using histcounts with the same set of bin edges for each call. Once you have the bin counts for each trial, add them together and call histogram with the bin counts and bin edges to plot it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!