Probabilty occurence of a number in long number sequence
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hiee
Is matlab has any function to count prob of occurrence of a particular no iin a long data sequence?
i.e. if I have 300 numbers ..all the the numbers varies from 0 to 255..then if no 8 occurs 3 times in the sequence,,then probability occurrence for 8 shall be 3/300.How can I calculate this in matlab? how can I plot this data in matlab
0 comentarios
Respuesta aceptada
Matt Fig
el 18 de Oct. de 2012
Editada: Matt Fig
el 18 de Oct. de 2012
X = randi(256,1,300)-1; % Data on [0 255]
P = histc(X,0:255)/length(X); % Probabilities.
[(0:255).' P(:)] % Show the probabilities.
plot(0:255,P)
If you only want to see the probabilities that are nonzero:
Y = 0:255;
Y = Y(logical(P));
P = P(logical(P));
[Y(:) P(:)]
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!