knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This document shows how to use SimpleSim to generate Guassian blobs to highlight how the package works.
The package is named SimpleSim and can be brought into your environment as:
library(SimpleSim)
Now we are ready to start using the functions. In what follows we will generate Gaussian blobs using the SimBlobs function.
Blobs are Isotropic Gaussians with varying numbers of centers. To generate eight blobs on a 2d place, each with N samples we can do the following:
blobs = SimBlobs(100, nFeatures = 2) plot(blobs$x[,1], blobs$x[,2], xlab = "x1", ylab = "x2", main = "2D Blobs")
The output of any SimpleSim function will be a list of simulated data. For blobs we get back x (a matrix whose rows represent observations), y (class labels for each blob) and centers (the centers for the generated blobs).
Below we play with some more features of the Blobs function.
# specifying the centers of each blob. centers = matrix(c(2,3,10,11), byrow = T, ncol = 2) blobs = SimBlobs(40, centers = centers) plot(blobs$x[,1], blobs$x[,2], xlab = "x1", ylab = "x2", main = "2D Blobs Centers Given")
You can also choose to have the centers of the blobs we uniformly generated within the interval given by centerBox.
closeBlobs = SimBlobs(40, centerBox = c(-1,1)) farBlobs = SimBlobs(40, centerBox = c(-100, 100)) par(mfrow = c(1,2)) plot(closeBlobs$x[,1], closeBlobs$x[,2], xlab = "x1", ylab = "x2", main = "2D Blobs Close") plot(farBlobs$x[,1], farBlobs$x[,2], xlab = "x1", ylab = "x2", main = "2D Blobs Far")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.