

Points normally distributed in a matlab square
source link: https://www.codesd.com/item/points-normally-distributed-in-a-matlab-square.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Points normally distributed in a matlab square
How can I create N normally distributed points within a N x N square with the mean at the centre (More points concentrated at the centre). I would appreciate an approach in which the coordinates of each points could be stored in a struct. I have tried the code below
for i=1:200
S(i).x=randn*200;
S(i).y=randn*200;
plot(S(i).x,S(i).y,'.');
axis([0 200 0 200]);
end
However, I observed I got negative values. Using a centre [mean] of (100,100) in a square, I want to store normally distributed points between 0-200 for a 200x200 square. Thanks
The following would require the Statistics Toolbox in MATLAB. You can create a truncated normal distribution, which by definition would only generate normally distributed random numbers within the range [0, N]
.
% Create a normal distribution
N = 200;
pd = makedist('Normal', 'mu', N/2, 'sigma', 60)
% Truncate the normal distribution to [0,N]
t = truncate(pd, 0, N)
% Samples from normal distribution
x = pd.random(N,1);
y = pd.random(N,1);
subplot(211)
plot(x,y,'bx')
title('Normal Distribution')
% Samples from truncated distribution
x = t.random(N,1);
y = t.random(N,1);
subplot(212)
plot(x,y,'ro')
title('Truncated Normal Distribution')
This would result in something like the following:
Recommend
-
44
The above video is hosted on egghead.io . It’s handy to inspect an el...
-
13
Quick Tip - Allow A Null Value For An Object That Doesn't Normally Allow It In the PowerShell Slack channel (powershell.slack.com) a question came up along the lines of “I have...
-
13
NEWS Scientists Create Simple Synthetic Cell That Grows and Divid...
-
3
John Fremlin's blog: Meta-programming normallyWaiting for updates: connectedPosted 2011-04-27 16:59:00 GMTThere was a time at Bell Labs when the so-called Area 10 fr...
-
4
Supplement that lower sugar levels normally
-
2
October 14, 2021
-
3
ConversationNVIDIA finally got back to me this evening about the new laptop parts. As it turns out - and despite the name- RTX 2050 is based on the GA107 Ampere GPU. So is MX570. RTX 2050 is, without a doubt, going to end up b...
-
5
How to Try YouTube TV for Free and How Much It Costs Normally By Joe Keeley Published 17 hours ago YouTube TV offers over...
-
3
Is UX Data Normally Distributed? Jeff Sauro, PhD • Jim Lewis, PhD ...
-
6
How to Get Normally Distributed Random Numbers With NumPy Remove ads Probability distribut...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK