I have a 100x100 Matrix with Zeros. I want to add a 10x20 ellipsis around a specific point in the Matrix - lets say at position 40,60. The Ellipsis should be filled with values from 0 to 1. (1 in the center - 0 at the edge) - The numbers should be gaussian-distributed. Maybe someone can give me a clue, how to start with this problem..
Asked
Active
Viewed 247 times
1 Answers
0
You need to draw samples from a multi-variate gaussian distribution. The function you can use is numpy.random.multivariate_normal
You mean value matrix should be [40, 60]
. The covariance C
matrix should be 2X2. Regarding its values:
C[1, 1], C[2, 2]: decides the width of the ellipse along each axis. Choose it so that 3*C[i,i]
is almost equal to the width of the ellipse along this axis.
The diagonal values are zero if you want the ellipse to be along the axes, otherwise put larger values (keep in mind that C[2, 1]==C[1, 2]
However, keep in mind that, since it is a Gaussian distribution, the output values will be close to 0 at distance 3*C[i,i]
from the center, but they will never be truly zero.

blue_note
- 27,712
- 9
- 72
- 90
-
Thank you for your reply. What I don't get is: With numpy.random.multivariate_normal I get points which are disributed in a ellipse with 10x20 as the center [40,60]; But there are no Values for the points, right? – bor32 Jun 06 '17 at 11:23
-
No, there are no values for points. The points either appear, on not. However, there is a probability that each point may appear. If you need that probability, see instead `https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.multivariate_normal.html` – blue_note Jun 06 '17 at 13:31