# Create a square grid with some random points inside that follow the poisson distribution and use each of these points as a starting point for my function

6 vues (au cours des 30 derniers jours)
george korris le 13 Jan 2023
Commenté : george korris le 4 Fév 2023
Hi everyone! Happy new year! I hope everyone is doing well!!
So I have a function that simulates dla (something like brownian motion). But I want to create a square grid with some random points inside of the grid that follow the poisson distribution and from each and everyone of those points call my function to simulate a small dla. Does anyone know how can I do this?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

William Rose le 13 Jan 2023
If you place a point at random in the unit square with rand(), then the the distribution of points inside small sub-squares will be approximately Poisson.
M=100; %number of simulations
N=200; %number of points per simulation
%Divide the unit square into a 10x10 grid of subsquares
counts=zeros(M,10,10); %number of points in each subsquare in each simulation
for i=1:M
pts=rand(N,2); %x,y coordinates of N points in the unit square
gridpts=floor(10*pts)+[1,1]; %convert point locaitons to indices in the subsquare grid
for j=1:N
counts(i,gridpts(j,1),gridpts(j,2))=counts(i,gridpts(j,1),gridpts(j,2))+1;
end
end
histogram(reshape(counts,1,M*100),'Normalization','pdf')
hold on
%% PLot expected Poisson distribution
lambda=N/100; %expected points per subsquare
k=0:10;
plot(k,lambda.^k.*exp(-lambda)./factorial(k),'-r')
legend('Observed','Expected')
This is the distribution of points in subsquares. The plot shows that the observed number of points per subsquare follows the expected Poisson distribution.
##### 13 commentairesAfficher 11 commentaires plus anciensMasquer 11 commentaires plus anciens
William Rose le 3 Fév 2023
Geroge, I see that you have posted this question separately elsewhere on this site, so I will think about it, and if I have an answer, I will post it there.
george korris le 4 Fév 2023
Thank you @William !!!

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by