plots with n = 10k

This commit is contained in:
Niclas
2026-04-28 13:19:46 +02:00
parent 9b702d154a
commit 0921f7eb04
2 changed files with 45 additions and 49 deletions

1
.gitignore vendored
View File

@@ -53,3 +53,4 @@ rsconnect/
/.quarto/
**/*.quarto_ipynb
_freeze/
.positai

View File

@@ -24,38 +24,26 @@ library(latex2exp)
```
## Setup
We consider the matrix $QQ^\top$ and look at the smallest eigenvalue, i.e. the
smallest non-zero singular value of $Q$.
## Setup
The matrix $Q$ is given by
$$
Q_{ik} = \int_{\frac{k}{K}}^{\frac{k+1}{K}} p_a(u| X_i) \, du
$$
with
$$
p_a(u|X) = \frac{f_v(F_a^{-1}(u) - a^\top X)}{f_a(F_a^{-1}(u))}
$$
In this document we plot different the smallest eigenvalue in dependence of the
parameter $a$ with different "ratios" of the parameters $n$ and
$$
k = \lfloor n^\alpha \rfloor
$$
We consider the matrix $QQ^\top$ and look at the smallest eigenvalue, i.e. the smallest non-zero singular value of $Q$.
with $\alpha = 0.1, 0.2, \dots 0.5$. The data matrix $X$ is a random matrix with
i.i.d. distributed entries. We consider $x_{ij} \sim U[0,1]$ and $x_{ij} \sim Exp(\lambda)$.
The matrix $Q$ is given by $$Q_{ik} = \int_{\frac{k}{K}}^{\frac{k+1}{K}} p_a(u| X_i) \, du$$ with $$p_a(u|X) = \frac{f_v(F_a^{-1}(u) - a^\top X)}{f_a(F_a^{-1}(u))}$$ In this document we plot different the smallest eigenvalue in dependence of the parameter $a$ with different "ratios" of the parameters $n$ and $$k = \lfloor n^\alpha \rfloor$$
with $\alpha = 0.1, 0.2, \dots 0.5$. The data matrix $X$ is a random matrix with i.i.d. distributed entries. We consider $x_{ij} \sim U[0,1]$ and $x_{ij} \sim Exp(\lambda)$.
## Exponential distribution
```{r k = n^alpha data generation, rate = 1}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 1000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results01 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -79,14 +67,15 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results01 <- rbind(results01, current_res)
}
}
}
```
```{r k = n^alpha plotting, rate = 1}
results |>
# plot the results
results01 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -105,17 +94,16 @@ results |>
shape=latex2exp::TeX("$\\alpha$"))
```
```{r k = n^alpha data generation, rate = 3}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 1000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results02 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -139,14 +127,14 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results02 <- rbind(results02, current_res)
}
}
}
```
```{r k = n^alpha plotting, rate = 3}
results |>
results02 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -164,18 +152,19 @@ results |>
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
For $a = 0$ the smallest singular value is very close to zero.
```{r k = n^alpha data generation, rate = 5}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 1000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results03 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -199,14 +188,14 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results03 <- rbind(results03, current_res)
}
}
}
```
```{r k = n^alpha plotting, rate = 5}
results |>
results03 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -224,21 +213,21 @@ results |>
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
Why is here a perfect match for $\alpha = 0.1$ and $a = 20$ to the square function?
The difference is of the order of $10^{-11}$!
Why is here a perfect match for $\alpha = 0.1$ and $a = 20$ to the square function? The difference is of the order of $10^{-11}$!
## Uniform distribution
```{r k = n^alpha data generation, U[0,1]}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 1000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results04 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -262,14 +251,14 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results04 <- rbind(results04, current_res)
}
}
}
```
```{r k = n^alpha plotting, U[0,1]}
results |>
results04 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -287,19 +276,19 @@ results |>
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
Here we have the same effect for $\alpha = 0.1$ and $a = 20$.
Here we have the same effect for $\alpha = 0.1$ and $a = 20$.
```{r k = n^alpha data generation, U[0,2]}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 1000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results05 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -323,14 +312,14 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results05 <- rbind(results05, current_res)
}
}
}
```
```{r k = n^alpha plotting, U[0,2]}
results |>
results05 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -348,16 +337,17 @@ results |>
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
```{r k = n^alpha data generation, N(0,1)}
#| cache: true
#| echo: false
#| collapse: true
ns <- seq(100, 5000, 100)
ns <- seq(100, 10000, 100)
as <- seq(0, 20, 2)
alphas <- seq(0.1, 0.5, 0.1)
set.seed(100)
results <- data.frame(dim_n = integer(),
results06 <- data.frame(dim_n = integer(),
dim_k = integer(),
param_a = double(),
param_alpha = double(),
@@ -382,14 +372,14 @@ for (a in as) {
ssv <- compute_minmax_sv(Q)[["smallest_singular_value"]]
current_res <- data.frame(dim_n = n, dim_k = K, param_a = a, param_alpha=alphas[j], ssv =ssv)
results <- rbind(results, current_res)
results06 <- rbind(results06, current_res)
}
}
}
```
```{r k = n^alpha plotting, U[0,2]}
results |>
results06 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -403,13 +393,13 @@ results |>
labs(x=latex2exp::TeX("$n$"),
y=latex2exp::TeX("Smallest singular value of $Q$"),
title=latex2exp::TeX("Smallest singular value of $Q$ with respect to $a$."),
subtitle = latex2exp::TeX(("Hyperparameter $k = n^{\\alpha}$. Black line is $\\sqrt{n}$, and $X \\sim N(0,1) $")),
subtitle = latex2exp::TeX(("Hyperparameter $k = n^{\\alpha}$. Black line is $\\sqrt{n}$, and $X \\sim N(0,1) $, use ceil function instead of floor for rounding.")),
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
```{r k = n^alpha plotting, U[0,2]}
results |>
results06 |>
filter(param_a %in% c(0, 10, 20)) |>
mutate(param_a = as.factor(param_a),
param_alpha = as.factor(param_alpha)) |>
@@ -426,4 +416,9 @@ results |>
subtitle = latex2exp::TeX(("Hyperparameter $k = n^{\\alpha}$. Black line is $\\sqrt{n}$, and $X \\sim N(0,1) $")),
colour=latex2exp::TeX("$a$"),
shape=latex2exp::TeX("$\\alpha$"))
```
```
```{r}
results <- list(results01, results02, results03, results04, results05, results06)
save(results, file="results.RData")
```