File:Distance Correlation Examples.svg

De Wikimedia Commons, el repositorio multimedia libre
Ir a la navegación Ir a la búsqueda

Archivo original(archivo SVG, nominalmente 506 × 318 píxeles, tamaño de archivo: 1,02 MB)

Leyendas

Leyendas

Añade una explicación corta acerca de lo que representa este archivo

Resumen

[editar]
Descripción
English: Recreation of File:Correlation_examples2.svg using the distance correlation method (dcor from the R energy library)
Fecha
Fuente Created in R using a modification of DenisBoigelot's script at File:Correlation_examples2.svg
Autor Naught101
Other information
#Title: An example of the correlation of x and y for various distributions of (x,y) pairs
#Tags: Mathematics; Statistics; Correlation
#Author: Denis Boigelot
#Packets needed : mvtnorm (rmvnorm), RSVGTipsDevice (devSVGTips)
#How to use: output()
#
#This is an translated version in R of an Matematica 6 code by Imagecreator.

library(mvtnorm)
library(energy)
library(RSVGTipsDevice)

MyPlot <- function(xy, xlim = c(-4, 4), ylim = c(-4, 4), eps = 1e-15) {
  title = round(dcor(xy[,1], xy[,2]), 1)
  if (sd(xy[,2]) < eps) title = "" # corr. coeff. is undefined
  plot(xy, main = title, xlab = "", ylab = "",
       col = "darkblue", pch = 16, cex = 0.2,
       xaxt = "n", yaxt = "n", bty = "n",
       xlim = xlim, ylim = ylim)
}

MvNormal <- function(n = 1000, cor = 0.8) {
  for (i in cor) {
     sd = matrix(c(1, i, i, 1), ncol = 2)
     x = rmvnorm(n, c(0, 0), sd)
     MyPlot(x)
  }
}

rotation <- function(t, X) return(X %*% matrix(c(cos(t), sin(t), -sin(t), cos(t)), ncol = 2))

RotNormal <- function(n = 1000, t = pi/2) {
  sd = matrix(c(1, 1, 1, 1), ncol = 2)
  x = rmvnorm(n, c(0, 0), sd)
  for (i in t)
     MyPlot(rotation(i, x))
}

Others <- function(n = 1000, spread = 1) {
  # x = seq(-1, 1, length.out = n) #generates a time series (serial dependence)
  x = runif(n, -1, 1) #same image, not a time series (no serial dependence)
  y = 4 * (x^2 - 1/2)^2 + runif(n, -1, 1) /3 * spread
  MyPlot(cbind(x,y), xlim = c(-1, 1), ylim = c(-1/3, 1+1/3))

  y = runif(n, -1, 1)
  xy = rotation(-pi/8, cbind(x,y))
  lim = sqrt(2+sqrt(2)) / sqrt(2)
  MyPlot(cbind(xy[,1], xy[,2]*spread), xlim = c(-lim, lim), ylim = c(-lim, lim))

  xy = rotation(-pi/8, xy)
  MyPlot(cbind(xy[,1], xy[,2]*spread), xlim = c(-sqrt(2), sqrt(2)), ylim = c(-sqrt(2), sqrt(2)))
  
  y = 2*x^2 + runif(n, -1, 1) * spread
  MyPlot(cbind(x,y), xlim = c(-1, 1), ylim = c(-1, 3))

  y = (x^2 + runif(n, 0, 1/2) * spread) * sample(seq(-1, 1, 2), n, replace = TRUE)
  MyPlot(cbind(x,y), xlim = c(-1.5, 1.5), ylim = c(-1.5, 1.5))

  y = cos(x*pi) + rnorm(n, 0, 1/8) * spread
  x = sin(x*pi) + rnorm(n, 0, 1/8) * spread
  MyPlot(cbind(x,y), xlim = c(-1.5, 1.5), ylim = c(-1.5, 1.5))

  xy1 = rmvnorm(n/4, c( 3,  3), diag(2)*spread)
  xy2 = rmvnorm(n/4, c(-3,  3), diag(2)*spread)
  xy3 = rmvnorm(n/4, c(-3, -3), diag(2)*spread)
  xy4 = rmvnorm(n/4, c( 3, -3), diag(2)*spread)
  MyPlot(rbind(xy1, xy2, xy3, xy4), xlim = c(-3-4, 3+4), ylim = c(-3-4, 3+4))
}

output <- function() {
  devSVGTips(width = 7, height = 4.4) # remove first and last line for no svg exporting
  par(mfrow = c(4, 7), oma = c(0,0,0,0), mar=c(2,2,2,0))
  MvNormal(800, c(1.0, 0.8, 0.4, 0.0, -0.4, -0.8, -1.0));
  RotNormal(200, c(0, pi/12, pi/6, pi/4, pi/2-pi/6, pi/2-pi/12, pi/2));
  Others(800)
  Others(800, 0.3)
  dev.off() # remove first and last line for no svg exporting
 
Este gráfico vectorial, sin especificar según el W3C, fue creado con R.

Licencia

[editar]
Yo, titular de los derechos de autor de esta obra, la publico en los términos de las siguientes licencias:
GNU head Se autoriza la copia, distribución y modificación de este documento bajo los términos de la licencia de documentación libre GNU, versión 1.2 o cualquier otra que posteriormente publique la Fundación para el Software Libre; sin secciones invariables, textos de portada, ni textos de contraportada. Se incluye una copia de la dicha licencia en la sección titulada Licencia de Documentación Libre GNU.
w:es:Creative Commons
atribución compartir igual
Este archivo se encuentra bajo la licencia Creative Commons Genérica de Atribución/Compartir-Igual 3.0.
Eres libre:
  • de compartir – de copiar, distribuir y transmitir el trabajo
  • de remezclar – de adaptar el trabajo
Bajo las siguientes condiciones:
  • atribución – Debes otorgar el crédito correspondiente, proporcionar un enlace a la licencia e indicar si realizaste algún cambio. Puedes hacerlo de cualquier manera razonable pero no de manera que sugiera que el licenciante te respalda a ti o al uso que hagas del trabajo.
  • compartir igual – En caso de mezclar, transformar o modificar este trabajo, deberás distribuir el trabajo resultante bajo la misma licencia o una compatible como el original.
Puedes usar la licencia que prefieras.

Historial del archivo

Haz clic sobre una fecha y hora para ver el archivo tal como apareció en ese momento.

Fecha y horaMiniaturaDimensionesUsuarioComentario
actual03:38 2 mar 2012Miniatura de la versión del 03:38 2 mar 2012506 × 318 (1,02 MB)Naught101 (discusión | contribs.){{subst:Upload marker added by en.wp UW}} {{Information |Description = {{en|Recreation of File:Correlation_examples2.svg using the distance correlation method (dcor from the R energy l...

No hay páginas que enlacen a este archivo.

Uso global del archivo

Las wikis siguientes utilizan este archivo:

Metadatos