how to give probability of 90% to unique values of a vector and 10% to repeated values?

조회 수: 1 (최근 30일)
Hello, how can I give 90% probability to elements of a vector that do not repeat themselves, and to elements that repeat 10%.
for example:
I have a vector
vector = [10 15 15 23 20 40]
give a probability of 90% to the numbers 10,23,20,40, and a probability of 10% to the numbers that are repeated, that is, 15,15.
and store it in a variable
thanks in advance
  댓글 수: 2
Rik
Rik 2021년 12월 15일
Have you already found a way to separate those two groups of numbers? That seems the first step to me. Then you can sample them in a 1:9 ratio.
giancarlo maldonado cardenas
giancarlo maldonado cardenas 2021년 12월 15일
separate them in what way?
vector = [10 23 20 40 15 15]
like that?

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

채택된 답변

Image Analyst
Image Analyst 2021년 12월 15일
Did you try a simple for loop?
vector = [10 15 15 23 20 40];
probabilities = zeros(1, length(vector));
for k = 1 : length(vector)
if sum(vector == vector(k)) >= 2
% Repeated
probabilities(k) = 0.1;
else
% Not repeated
probabilities(k) = 0.9;
end
end
probabilities % Show in command window.
probabilities = 1×6
0.9000 0.1000 0.1000 0.9000 0.9000 0.9000
  댓글 수: 5
Image Analyst
Image Analyst 2021년 12월 22일
Oh, OK, great! You're welcome. Thanks for Accepting my Answer. 😃
giancarlo maldonado cardenas
giancarlo maldonado cardenas 2022년 2월 18일
Hello my friend how are you? I hope it's ok.
could you help me with this question? https://la.mathworks.com/matlabcentral/answers/1652655-how-can-i-choose-non-repeating-values-with-a-probability-of-90-and-10
is very similar to this question
Thanks in advance

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by