Created
May 18, 2023 15:36
-
-
Save mschauer/a159628d635996c1abb938936ad431b2 to your computer and use it in GitHub Desktop.
Hidden correlation
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
using GLMakie | |
using Random | |
# mixture distribution | |
X(c) = rand() < c ? sqrt(rand()) : 1 - sqrt(rand()) | |
# sample | |
Random.seed!(1); | |
A = [0:0.01:1;; X.(0:0.01:1)]; | |
# correlation | |
cor(A) | |
# 2×2 Matrix{Float64}: | |
# 1.0 0.284633 | |
# 0.284633 1.0 | |
# plot | |
fig = Figure() | |
ax = Axis(fig[1,1]) | |
scatter!(ax, A) | |
ax = Axis(fig[1,2]) | |
image!(ax, [x*y + (1-x)*(1-y) for x in 0:0.1:1, y in 0:0.01:1], colormap=:viridis ) | |
save("density.png", fig) | |
Author
mschauer
commented
May 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment