Probability of occurrence as a function of distance

3 views (last 30 days)
Assume
% each color type represented by another integer
color=[5;3;4;3;5;4;4;5;16;4;16;4;16;16;16;4;16;16];
% corresponding distance in meters at which the color values occur away from point of origin zero.
distance=[0.3;0.9;4.2;5.1;7;8.8;12;15.3;19;26.1;27;29.6;34;36;41;43;51;58];
How can I calculate which color number is more likely to occur closer to distance 0 and which one further away from it and plot the results in a distribution plot with P10, P50 and P90 for each color?
PS: I use Matlab R2018b including Statistics and Machine Learning Toolbox.
PS2: please provide an answer which works with these two simple input arrays
  2 Comments
Walter Roberson
Walter Roberson on 6 May 2020
Are pixels constant size? If so then adjustment needs to be made for the fact that there are more pixels at a given radius as you get further away. You could, for example, weight each count by dividing it by the square of the distance it occurs at. However, you were indeed talking about probability of counts occuring in circular rings around an origin, I would expect to see a number of distances that were nearly the same.
Florian
Florian on 6 May 2020
Edited: Florian on 6 May 2020
HI Walter,
'color' is just a name for any attribute. The distance is in 1D, not 3D.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 6 May 2020
findgroups() and grpstats(), probably with prctile()
  4 Comments
Walter Roberson
Walter Roberson on 8 May 2020
You do not even need the cell wrapper.
% each color type represented by another integer
color=[5;3;4;3;5;4;4;5;16;4;16;4;16;16;16;4;16;16];
% corresponding distance in meters at which the color values occur away from point of origin zero.
distance=[0.3;0.9;4.2;5.1;7;8.8;12;15.3;19;26.1;27;29.6;34;36;41;43;51;58];
[G, ID] = findgroups(color);
stats = [ID, splitapply(@(M) prctile(M, [10 50 90]), distance, G)];
stats =
3 0.9 3 5.1
4 4.66 19.05 41.66
5 0.3 7 15.3
16 20.6 36 56.6
I am not sure how much easier you are striving for ?
Florian
Florian on 8 May 2020
Perfect, Walter! Thank you so much for providing this explanation!

Sign in to comment.

More Answers (0)

Categories

Find more on Time Series in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!