Purpose
To view various norms defined on the unit circle

Different Notions of length

> library(RColorBrewer)
> N <- 50000
> z <- cbind(runif(N, min = -1, max = 1), runif(n = 1000, min = -1,
+     max = 1))
> z <- as.data.frame(z)
> colnames(z) <- c("x", "y")
> cols <- brewer.pal(4, "Set1")
> norm1 <- function(x) {
+     if (sum(abs(x)) < 1) {
+         return(1)
+     }
+     else {
+         return(0)
+     }
+ }
> z1 <- z
> z1$n1 <- apply(z1, 1, norm1)
> z1 <- subset(z1, n1 == 1, select = c(x, y))
> norm2 <- function(x) {
+     if (sum(abs(x^2))^(0.5) < 1) {
+         return(1)
+     }
+     else {
+         return(0)
+     }
+ }
> z2 <- z
> z2$n2 <- apply(z2, 1, norm2)
> z2 <- subset(z2, n2 == 1, select = c(x, y))
> norm3 <- function(x) {
+     if (max(abs(x)) < 1) {
+         return(1)
+     }
+     else {
+         return(0)
+     }
+ }
> z3 <- z
> z3$n3 <- apply(z3, 1, norm3)
> z3 <- subset(z3, n3 == 1, select = c(x, y))
> norm4 <- function(x) {
+     if ((sum(abs(x^4)))^0.25 < 1) {
+         return(1)
+     }
+     else {
+         return(0)
+     }
+ }
> z4 <- z
> z4$n4 <- apply(z4, 1, norm4)
> z4 <- subset(z4, n4 == 1, select = c(x, y))
> library(grid)
> par(mfrow = c(2, 2))
> plot(z1, col = cols[1], main = "NORM 1")
> plot(z2, col = cols[2], main = "NORM 2")
> plot(z3, col = cols[3], main = "NORM 3")
> plot(z4, col = cols[4], main = "NORM 4")

Lecture_4-001.jpg