How to randomly sample a value multiple times from data

3 vues (au cours des 30 derniers jours)
EcoBase
EcoBase le 27 Jan 2022
Réponse apportée : KSSV le 27 Jan 2022
Hi.
I have a dataset containing x, y, z coordinates with which I can draw a 2D figure as below:
What I want to do is to sample a value randomly multiple times (e.g 2,000 times) from Z values within the black circle (ind = (Y-65).^2 + (X-85).^2 <= 45^2;). Z values within the circle range from 0 to 65. Then I'd like to analyze the probability that the sampled values are greater (or less) than 15.
Could you help me with this task?
Thanks in advance.

Réponses (1)

KSSV
KSSV le 27 Jan 2022
Let x,yz be your data. (May be column or matrix)
idx = (X-85).^2 + (Y-65).^2 <= 45^2;
% get the required indices data of (x,y)
x1 = x(idx) ; y1 = y(idx) ; % this will be a column matrix
n = length(x) ; % total points
% select random 100 random points in (x,y) 10 times
for i = 1:10
id = randi(n,1,100) ; % you can keep your number less than n
xi = x(id) ;
yi = y(id) ;
% do what you want
end

Community Treasure Hunt

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

Start Hunting!

Translated by