add plots for singular values vs variance
This commit is contained in:
93
scripts/plot_sv_dependence_n.R
Normal file
93
scripts/plot_sv_dependence_n.R
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Load function ----------------------------------------------------------------
|
||||||
|
source(here::here("R", "singular_values.R"))
|
||||||
|
source(here::here("R", "graphon_distribution.R"))
|
||||||
|
source(here::here("R", "singular_value_plot.R"))
|
||||||
|
|
||||||
|
# https://stackoverflow.com/a/5790430
|
||||||
|
resetPar <- function() {
|
||||||
|
dev.new()
|
||||||
|
op <- par(no.readonly = TRUE)
|
||||||
|
dev.off()
|
||||||
|
op
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Compare of parameters of Normal distribution ----------------------------------
|
||||||
|
#
|
||||||
|
out_n400_sd05 <- smallest_sv_sequence(
|
||||||
|
a = c(0.5),
|
||||||
|
n = 400,
|
||||||
|
maxK = 20,
|
||||||
|
sampler_fn =function(n) matrix(rnorm(n), ncol = 1L),
|
||||||
|
guard=1e-12,
|
||||||
|
plot=TRUE,
|
||||||
|
log_plot = TRUE,
|
||||||
|
fv = function(x) {dnorm(x, mean=0, sd=0.5)},
|
||||||
|
Fv = function(x) {pnorm(x, mean=0, sd=0.5)},
|
||||||
|
main_title="Smallest SV of v~ N(0,0.5^2) distribution, n = 400"
|
||||||
|
)
|
||||||
|
|
||||||
|
out_n800_sd05 <- smallest_sv_sequence(
|
||||||
|
a = c(0.5),
|
||||||
|
n = 800,
|
||||||
|
maxK = 20,
|
||||||
|
sampler_fn =function(n) matrix(rnorm(n), ncol = 1L),
|
||||||
|
guard=1e-12,
|
||||||
|
plot=TRUE,
|
||||||
|
log_plot = TRUE,
|
||||||
|
fv = function(x) {dnorm(x, mean=0, sd=0.5)},
|
||||||
|
Fv = function(x) {pnorm(x, mean=0, sd=0.5)},
|
||||||
|
main_title="Smallest SV of v~ N(0,0.5^2) distribution, n=800"
|
||||||
|
)
|
||||||
|
|
||||||
|
out_n400_sd2 <- smallest_sv_sequence(
|
||||||
|
a = c(0.5),
|
||||||
|
n = 400,
|
||||||
|
maxK = 20,
|
||||||
|
sampler_fn =function(n) matrix(rnorm(n), ncol = 1L),
|
||||||
|
guard=1e-12,
|
||||||
|
plot=TRUE,
|
||||||
|
log_plot = TRUE,
|
||||||
|
fv = function(x) {dnorm(x, mean=0, sd=2)},
|
||||||
|
Fv = function(x) {pnorm(x, mean=0, sd=2)},
|
||||||
|
main_title="Smallest SV of v~ N(0,2^2) distribution, n=400"
|
||||||
|
)
|
||||||
|
|
||||||
|
out_n800_sd2 <- smallest_sv_sequence(
|
||||||
|
a = c(0.5),
|
||||||
|
n = 800,
|
||||||
|
maxK = 20,
|
||||||
|
sampler_fn =function(n) matrix(rnorm(n), ncol = 1L),
|
||||||
|
guard=1e-12,
|
||||||
|
plot=TRUE,
|
||||||
|
log_plot = TRUE,
|
||||||
|
fv = function(x) {dnorm(x, mean=0, sd=2)},
|
||||||
|
Fv = function(x) {pnorm(x, mean=0, sd=2)},
|
||||||
|
main_title="Smallest SV of v~ N(0,4^2) distribution,n = 800"
|
||||||
|
)
|
||||||
|
|
||||||
|
par(mar = c(5, 4, 4, 8))
|
||||||
|
plot(out_n400_sd05$K, out_n400_sd05$sv,
|
||||||
|
type = "b",
|
||||||
|
pch = 19,
|
||||||
|
col = "#D3BA68FF",
|
||||||
|
xlab = "K subdivisions",
|
||||||
|
ylab = "Smallest singular value of Q",
|
||||||
|
main="smallest SV for different variances of a normal distribution",
|
||||||
|
sub = "n = 400, a = 0.5",
|
||||||
|
log="y")
|
||||||
|
lines(out_n400_sd2$K, out_n400_sd2$sv,
|
||||||
|
type="b", pch=19, col="#D5695DFF", add=TRUE)
|
||||||
|
lines(out_n800_sd05$K, out_n800_sd05$sv,
|
||||||
|
type = "b", pch=19, col="#5D8CA8FF", add=TRUE)
|
||||||
|
lines(out_n800_sd2$K, out_n800_sd2$sv,
|
||||||
|
type = "b", pch=19, col="#65A479FF", add=TRUE)
|
||||||
|
par(xpd = TRUE)
|
||||||
|
legend("topright",
|
||||||
|
inset=c(-0.2,0),
|
||||||
|
legend=c("sd=0.5, n=400", "sd=0.5, n=800", "sd=2, n=400", "sd=2, n=800"),
|
||||||
|
col=c("#D3BA68FF", "#D5695DFF","#5D8CA8FF", "#65A479FF" ),
|
||||||
|
title="Legend",
|
||||||
|
pch = 16,
|
||||||
|
bty = "n")
|
||||||
Reference in New Issue
Block a user