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
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일

1 개 추천

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

I would try this. But, do you want me to store my data of each instant in datasets? And, edges- how do I specify? Here you use rand function, but in my case, it won't be so.
counts is a 2-D array. Each row of counts is the histogram for a dataset. Replace edges with something not using rand and using your data, something like
edges = linspace(minPossibleValue, maxPossibleValue, numBins);
where the two values are something you determine in advance, perhaps by pre-scanning your data to check what those values might be if you don't have advance expert knowledge of the values would be.
Thanks. It worked.
What is datasets variable here?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2017년 6월 7일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by