Learn R Programming

snn (version 1.1)

mydata: Data Generator

Description

Generate random data from mixture Gaussian distribution.

Usage

mydata(n, d, mu = 0.8, portion = 1/2)

Arguments

n
The number of observations (sample size).
d
The number of variables (dimension).
mu
In the Gaussian mixture model, the first Gaussian is generated with zero mean and identity covariance matrix. The second Gaussian is generated with mean a d-dimensional vector with all mu and identity covariance matrix.
portion
The prior probability for the first Gaussian component.

Value

Return the data matrix with n rows and d + 1 columns. Each row represents a sample generated from the mixture Gaussian distribution. The first d columns are features and the last column is the class label of the corresponding sample.

Examples

Run this code

	set.seed(1)
	n = 100
	d = 10
	DATA = mydata(n, d)
	
	DATA.x = DATA[,1:d]
	DATA.y = DATA[,d+1]
	

Run the code above in your browser using DataLab