필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Question about 'histc' expression

조회 수: 1 (최근 30일)
Mary
Mary 2011년 10월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
hello, i have a general question about the histogram function ('hist'/'histc').
i use a histogram to plot my data. my data are basically vectors of different length and i need to know how many of the vectors will contribute a value to each bin (in the first bins all vectors will contribute, whereas in the later ones, hardly any will contribute). i found some code from someones which addresses this problem and the script runs, but i don't quite understand what it exactly does and if it really does what i want. if someone could 'translate' the expression, i'd be really grateful:
p = (histc (ts, edges))/(length(ts)*binsize))
thanks a lot in advance!
  댓글 수: 1
Jan
Jan 2011년 10월 27일
Without seeing the definition of "edges", "ts" and "binsize" we had to guess. This will not be very helpful. Please edit your question and insert the necessary details.

답변 (2개)

the cyclist
the cyclist 2011년 10월 27일
As Jan mentions, we don't have all the details, so there is some guessing involved, but here is what I would conclude based on what you have told us.
As you can learn from reading "doc histc", the histc() command is going to give bin counts based on your data (your variable "ts") and the definition of the bin edges (your variable "edges".)
This code looks like might be trying to convert those counts into some kind of normalized count, or possibly the probability density function, by dividing by the expected. It's not possible to be certain, without knowing what "binsize" is. If "p" always sums to approximately "1", then it's probably the pdf.
  댓글 수: 1
Jan
Jan 2011년 10월 27일
I still hope that some of the posters can be motivated to add the necessary details. So I did not dare to guess. You did. +1

Mary
Mary 2011년 10월 28일
i use a histogram to plot my data. my data are basically vectors of different length and i need to know how many of the vectors will contribute a value to each bin (in the first bins all vectors will contribute, whereas in the later ones, hardly any will contribute). i found some code from someones which addresses this problem and the script runs, but i don't quite understand what it exactly does and if it really does what i want. if someone could 'translate' the expression, i'd be really grateful:
p = (histc (ts, edges))/(length(ts)*binsize))
thanks a lot in advance!
--------------------------------------------------------
sorry for not giving enough information on my problem. but thank you already for your answers.
so here's a more complete excerpt from the code:
for u = 1:length (Class.Condition01)
ts = Class.Condition01(1,u).ts;
p = (histc (ts, edges))/(length(ts)*binsize);
end
binsize = 0.01
edges = [-0.5:0.01:7]
ts is a vector in which my data is stored.
In the structure "Class.Condition01" several vectors of different length are stored.
As you have guessed, I want to do a normalization. In every loop, I need to divide the count in every bin by the number of vectors which have contributed values to a bin. And I'm really not sure if the term "/(length(ts)*binsize)" is doing that, because I don't quite understand what the term does to the histc expression. If you could explain to me what it does, I'd be very grateful. And if you have a suggestion to how I do the normalization properly, I'd also be very grateful. :)
  댓글 수: 2
Jan
Jan 2011년 10월 28일
Please add details by adding the original question. This is a section for answers.
Mary
Mary 2011년 10월 28일
i will. sorry!

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by