knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Introduction

This document shows how to use SimpleSim to generate Guassian blobs to highlight how the package works.

Getting Started

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

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).

Changing Centers

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")

Changing Bounding Box

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")


feji3769/simplesim documentation built on Dec. 12, 2020, 10:16 a.m.