% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_signal.R
\name{simulate_piecewise_signal_idx}
\alias{simulate_piecewise_signal_idx}
\title{Simulate a Piecewise-Constant Signal with Smooth Trend and Noise}
\usage{
simulate_piecewise_signal_idx(
  n = 1000,
  domain = c(-4, 4),
  changepoints_idx = c(300, 700),
  shift_sizes = c(0.5, -0.3, 0.7),
  noise_sd = 0.04,
  smooth_fun = function(x) 0.01 * (3 * x/2 - x^3/2),
  seed = NULL
)
}
\arguments{
\item{n}{Integer. Length of the signal.}

\item{domain}{Numeric vector of length 2 giving the range of the time axis.}

\item{changepoints_idx}{Integer vector of changepoint locations (indices).
Must lie strictly inside \eqn{(1, n)}.}

\item{shift_sizes}{Numeric vector giving the mean level of each segment.
Must have length equal to \code{length(changepoints_idx) + 1}.}

\item{noise_sd}{Numeric. Standard deviation of the Gaussian noise.}

\item{smooth_fun}{Function. A function \eqn{f(t)} defining the smooth trend.}

\item{seed}{Optional integer. If supplied, sets the random seed for reproducibility.}
}
\value{
A list with components:
\describe{
\item{t}{Time grid of length \eqn{n}.}
\item{smooth}{Smooth component \eqn{f(t)}.}
\item{step}{Piecewise-constant step component.}
\item{z}{Final noisy signal.}
\item{changepoints_idx}{Sorted changepoint indices.}
\item{shift_sizes}{Segment means.}
\item{params}{List of simulation parameters.}
}
}
\description{
Generate a univariate signal composed of:
\itemize{
\item a smooth deterministic component,
\item a piecewise-constant step component defined by changepoint indices,
\item additive Gaussian noise.
}
}
\details{
This function is useful for benchmarking changepoint detection algorithms
and reproducing controlled simulation studies.
}
\examples{
sim <- simulate_piecewise_signal_idx(
  n = 1000,
  changepoints_idx = c(300, 700),
  shift_sizes = c(0.5, -0.3, 0.7),
  noise_sd = 0.05,
  seed = 123
)

}
