% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_fd.R
\name{simulate_fd}
\alias{simulate_fd}
\title{Simulate a Two-Group Functional Dataset}
\usage{
simulate_fd(
  n0 = 50L,
  n1 = 50L,
  M = 100L,
  sigma = 0.4,
  A0 = 1,
  A1 = 1,
  f0 = 1,
  f1 = 1,
  seed = NULL
)
}
\arguments{
\item{n0}{Number of curves in group 0.  Default 50.}

\item{n1}{Number of curves in group 1.  Default 50.}

\item{M}{Number of time points.  Default 100.}

\item{sigma}{Standard deviation of the noise.  Default 0.4.}

\item{A0, A1}{Amplitudes of the mean functions.  Both default to 1.}

\item{f0, f1}{Frequencies of the mean functions.  Both default to 1.}

\item{seed}{Optional integer seed.}
}
\value{
A list with:
\describe{
\item{\code{X}}{Numeric matrix \eqn{(n_0+n_1) \times M}.}
\item{\code{y}}{Integer vector of labels (0 or 1).}
\item{\code{grid}}{Numeric vector of length \eqn{M} on \eqn{[0,1]}.}
}
}
\description{
Generates a labelled functional dataset from two Gaussian processes,
useful for illustrating and testing the classifiers in \code{fdclassify}.
The two groups differ in their mean function:
\deqn{
  x_i(t) = \mu_g(t) + \varepsilon_i(t), \quad
  \varepsilon_i(t) \sim \mathcal{GP}(0, \sigma^2),
}
where \eqn{\mu_0(t) = A_0 \sin(2\pi f_0 t)} and
\eqn{\mu_1(t) = A_1 \cos(2\pi f_1 t)} by default.
}
\examples{
dat <- simulate_fd(n0 = 40, n1 = 40, seed = 1)
matplot(t(dat$X[dat$y == 0, ]), type = "l", col = "steelblue",
        lty = 1, xlab = "t", ylab = "x(t)", main = "Simulated curves")
matlines(t(dat$X[dat$y == 1, ]), col = "firebrick", lty = 1)
legend("topright", legend = c("Group 0", "Group 1"),
       col = c("steelblue","firebrick"), lty = 1)

}
