Random values from histogram
Ältere Kommentare anzeigen
Hi
how i can use one value at the time from histogram and after use that value is deleted and i cannot use that again eg. if i have
x=rand(1,100)
[N,X]=hist(x,15)
bar(X,N,1,'w')
i want to get 100 values one by one
Thanks a lot
2 Kommentare
Oleg Komarov
am 8 Feb. 2011
I don't understand what are you asking.
niko kauppinen
am 8 Feb. 2011
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 8 Feb. 2011
1 Stimme
Okay, then, what this is equivalent to is taking each bar count as a run-length encoding of the value associated with that bar (e.g., the bar center), then doing a randperm() of that expanded vector.
I know a couple of people have posted efficient run-length decoding routines; I just don't happen to remember one at the moment.
Walter Roberson
am 8 Feb. 2011
x(randperm(1:length(x))
The histogram becomes irrelevant. Each item will occur exactly the number of times it did in the original list.
3 Kommentare
Andrew Newell
am 8 Feb. 2011
That is what niko seems to be asking, but what is the point of a random rearrangement of numbers that are already randomly chosen?
Walter Roberson
am 8 Feb. 2011
Hmmm... the bar _counts_ are what are to be chosen from, perhaps? But if so then should the bar count decrease one one of the items from that bar is "used up", or should the bar count itself stay the same but the number of repetitions of it "available" decreases?
Or perhaps it is the bar _index_ that needs to be chosen randomly, in accordance with the counts?
niko kauppinen
am 8 Feb. 2011
Kategorien
Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!