
# Linear regression

random_linear = function(n, alpha, beta, sigma) {
  x <- runif(n, 0, 10)
  y <- rnorm(n, mean = alpha + beta * x, sd = sigma)
  return(data = list(N=n, x=x, y=y))
}


random_gaussian_mixture = function(n_gaussian, n_per_gaussian, means, sigmas) {
  y = c()
  for (i in 1:n_gaussian) {
    y <- c(y, rnorm(n = n_per_gaussian[i], mean=means[i], sd=sigmas[i]))
  }
  return(data = list(N=sum(n_per_gaussian), y=y, K=n_gaussian))
}


#first cluster
mixture_of_2d_gaussians <- function(n_gaussians, n_per_gaussian, means_x, means_y, sigmas) {
  norm = NULL
  for (i in 1:n_gaussians) {
    sigma = matrix(c(sigmas[i],0,0,sigmas[i]), ncol=2, nrow = 2, byrow = TRUE)
    mu = c(means_x[i], means_y[i])
    norm_i <- MASS::mvrnorm(n_per_gaussian[i], mu, sigma)
    norm = rbind(norm, norm_i)
  }

  y=array(as.vector(norm), dim=c(sum(n_per_gaussian), 2))
  return(list(D=2, K=n_gaussians, N=sum(n_per_gaussian), y=y))
}
