Created
February 23, 2021 22:57
-
-
Save olekscode/f4a7a4d1aa15e23ae09e17993409fcec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numberOfPoints := 10000. | |
scale := 30. | |
pointExtent := 2@2. | |
color1 := Color fromString: '3288BD'. | |
color2 := Color fromString: 'D53E4F'. | |
mu1 := #(1 0) asPMVector. | |
mu2 := #(-1.5 -1) asPMVector. | |
sigma1 := PMMatrix rows: #( | |
(0.5 1) | |
(1 3)). | |
sigma2 := PMMatrix rows: #( | |
(1 0.8) | |
(0.8 1)). | |
dist1 := PMMultivariateNormalDistribution | |
meanVector: mu1 | |
covarianceMatrix: sigma1. | |
dist2 := PMMultivariateNormalDistribution | |
meanVector: mu2 | |
covarianceMatrix: sigma2. | |
data1 := (1 to: numberOfPoints) collect: [ :i | dist1 random ]. | |
data2 := (1 to: numberOfPoints) collect: [ :i | dist2 random ]. | |
canvas := RSCanvas new. | |
data1 do: [ :each | | |
canvas add: (RSEllipse new | |
extent: pointExtent; | |
x: each first * scale; | |
y: each second * scale; | |
color: color1; | |
yourself) ]. | |
data2 do: [ :each | | |
canvas add: (RSEllipse new | |
extent: pointExtent; | |
x: each first * scale; | |
y: each second * scale; | |
color: color2; | |
yourself) ]. | |
canvas open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment