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
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
So, why don't you start taking small enough time windows and let us know?
John BG
Arghadwip Paul
Arghadwip Paul 2017-6-8
Ergodic means when the process will be independent of the initial state. I have done simulations till the time when I don't observe significant changes in my system. I would now want to average over the data of time instants(delta t=10^(-4)). What do you think?

请先登录,再进行评论。

采纳的回答

Walter Roberson
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
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.

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by