필터 지우기
필터 지우기

how can I find the probabilities of the ecdf function of each duplicate values in y ?

조회 수: 3 (최근 30일)
I have a vector that has dublicate values (y). I need to extract each value probabitiy even if its duplicate. here is my code.
num_off_time=[2 2 3 3 1];
y=num_off_time;
[f,x]=ecdf(y);
cdfplot(y)

채택된 답변

the cyclist
the cyclist 2020년 1월 27일
Do you mean you are trying to get these values?
histcounts(num_off_time,'Normalization','probability')
ans =
0.2000 0.4000 0.4000
  댓글 수: 4
talal alqahtani
talal alqahtani 2020년 1월 28일
I would expect if Y=[2 2 3 3 1], The output for example would be like this: [0.30 0.30 0.50 0.50 0.10] instead of [0.30 0.50 0.10]. I hope this is clear . Thank you .
the cyclist
the cyclist 2020년 1월 28일
It's not clear to me where you are getting your values of [0.3 0.5 0.1], because those don't seem to be probabilities related to your input vector.
So, here's what it seems like you want to do:
  1. Find the total probability of each channel.
  2. For each channel, output its probability, indexed according to the original input vector.
This code does that. I added an extra "3" to your input, to show that 2 and 3 give different output.
num_off_time=[2 2 3 3 3 1];
[unique_num_off_time,~,idxFromUniqueBackToAll] = unique(num_off_time);
probability_of_unique = histcounts(num_off_time,[unique_num_off_time Inf],'Normalization','probability');
probability_by_channel = probability_of_unique(idxFromUniqueBackToAll);
This gives
probability_by_channel =
0.3333 0.3333 0.5000 0.5000 0.5000 0.1667

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by