diff --git a/DESCRIPTION b/DESCRIPTION index 5a2471d..4265738 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ Imports: ggplot2, stats LinkingTo: Rcpp, RcppArmadillo -RoxygenNote: 6.1.1 +RoxygenNote: 7.0.2 Suggests: knitr, rmarkdown, diff --git a/NAMESPACE b/NAMESPACE index ec4d443..8bd24d8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,13 +1,19 @@ # Generated by roxygen2: do not edit by hand +export() export(beamSearch) export(convert10to4) +export(convertdynamicstates) export(ddirichlet) export(getloglike) export(kalman) export(musicModel) +export(musicModeldynamics) export(plotStates) +export(plotStates2) export(rdirichlet) +export(resampleOptimal) +export(resampleSubOptimal) import(ggplot2) importFrom(Rcpp,evalCpp) importFrom(Rcpp,sourceCpp) diff --git a/R/RcppExports.R b/R/RcppExports.R index ec28fd8..64050b1 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1,243 +1,294 @@ -# Generated by using Rcpp::compileAttributes() -> do not edit by hand -# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#' Fast likelihood evaluation given parameters and discrete states -#' -#' This function quickly computes the (negative) log likelihood for a possibly -#' time varying state-space model. The goal is to enable ML (or Bayesian) estimation -#' of parameters without extra computational overhead -#' -#' @param pmats a list of parameter matrices for the kalman filter. -#' This can either be the output of \code{\link{musicModel}}, or a list with -#' the same names as the output of \code{\link{musicModel}}. This list must contain -#' the following elements: \code{a0, P0, dt, ct, Tt, Zt, HHt, GGt}. See the details below. -#' @param path vector giving the path for hidden discrete states -#' @param y observations, each time point in a column -#' -#' @return the negative log-likelihood -#' -#' @details -#' \describe{ -#' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} -#' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} -#' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} -#' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} -#' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} -#' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} -#' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} -#' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} -#' } -#' -#' @examples -#' data(tempos) -#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, -#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, -#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) -#' y = matrix(tempos[,'Richter_1976'], 1) -#' lt = diff(c(tempos$note_onset, 61)) -#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], -#' c(132,0), c(400,10)) # prior means and variances on X_1 -#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, -#' HHt, GGt, y, transMat, 200)) -#' bestpath = with(beam, paths[which.max(weights),]) -#' getloglike(pmats, bestpath, y) -#' -#' @export -getloglike <- function(pmats, path, y) { - .Call('_dpf_getloglike', PACKAGE = 'dpf', pmats, path, y) -} - -#' Parameter matrices for our music model -#' -#' This function accepts a number of parameters and creates a list of matrices -#' for Kalman filter evaluation. See the paper for the particular form of the model. -#' -#' @param lt vector of durations between successive notes in the score -#' @param sig2eps variance of the observation noise -#' @param mus vector of 3 mean parameters (\eqn{\mu, \tau, and \varphi}) -#' @param sig2eta vector of 3 state variance parameters (\eqn{\sigma_3^2, \sigma_2^2,and \sigma_4^2}) -#' @param transprobs vector of 7 transition probabilities -#' @param initialMean a vector of length 2 giving the prior tempo and the prior acceleration for when state 1 or 3 is the starting state -#' @param initialVariance a vector of length 2 giving the prior variance for the tempo and the prior variance for the acceleration for when state 1 or 3 is the starting state -#' -#' @return List with components as appropriate for Kalman filtering or Beam Search. These include: \describe{ -#' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} -#' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} -#' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} -#' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} -#' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} -#' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} -#' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} -#' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} -#' \item{transMat}{a dxd matrix of transition probabilities for the discrete states} -#' } -#' -#' @examples -#' data(tempos) -#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, -#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, -#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) -#' y = matrix(tempos[,'Richter_1976'], 1) -#' lt = diff(c(tempos$note_onset, 61)) -#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], -#' c(132,0), c(400,10)) -#' -#' @export -musicModel <- function(lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance) { - .Call('_dpf_musicModel', PACKAGE = 'dpf', lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance) -} - -#' Greedy HMM estimation given continuous hidden states -#' -#' This function maintains a "beam" of size \code{N} representing the highest likelihood -#' states up to time \code{t}. For a typical switching state space model, ML evaluation -#' requires computing each of the \code{d^N} possible paths through the discrete -#' state space. Beam Search greedily approximates these computations be propagating -#' the most likely states at each time point. -#' -#' @param a0 a pxd matrix of state prior means, where the i'th column is the mean for the i'th state -#' @param P0 a (p^2)xd state prior covariance matrix, where the i'th column is the covariance matrix stored columnwise for the i'th state -#' @param w0 a vector specifying the prior probability of starting in each of the d discrete states -#' @param dt a pxdxn (or pxdx1 if all n slices are the same) cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i. -#' @param ct a kxdxn (or kxdx1 if all n slices are the same) cube of observation intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i. -#' @param Tt a (p^2)xdxn (or (p^2)xdx1 if all n slices are the same) cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i. -#' @param Zt a pkxdxn (or pkxdx1 if all n slices are the same) cube of obvervation slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i. -#' @param HHt a (p^2)xdxn (or (p^2)xdx1 if all n slices are the same) cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i. -#' @param GGt a (k^2)xdxn (or kxdx1 if all n slices are the same) cube of observation covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i. -#' @param yt a kxn matrix of obervations -#' @param transProbs a dxd matrix of transition probabilities for the discrete states -#' @param N the maximum particle number -#' -#' @return List with components "paths", "weights", and "LastStep". -#' \describe{ -#' \item{"paths"}{is an Nxn matrix specifying the paths of each particle,} -#' \item{"weights"}{is a vector giving the final sampling weight of each path,} -#' \item{"LastStep"}{is the timestep computed. "LastStep" will alway equal n unless all of the sampling weights vanish.} -#' } -#' -#' @examples -#' data(tempos) -#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, -#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, -#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) -#' y = matrix(tempos[,'Richter_1976'], 1) -#' lt = diff(c(tempos$note_onset, 61)) -#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], -#' c(132,0), c(400,10)) # prior means and variances on X_1 -#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, -#' HHt, GGt, y, transMat, 200)) -#' -#' @export -beamSearch <- function(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N) { - .Call('_dpf_beamSearch', PACKAGE = 'dpf', a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N) -} - -#' Estimate continuous states given parameters and discrete hidden states -#' -#' Performs Kalman filtering and smoothing for the switching state space model. -#' Also works on any (potentially time varying) state space model. -#' -#' @param pmats a list with componente \code{a0, P0, dt, ct, Tt, Zt, HHt,} and \code{GGt} -#' e.g., as output from musicModel. See the details below. -#' @param path path of discrete hidden states -#' @param y observations -#' -#' @return List with components from Kalman filter and Smoother. See details. -#' -#' @details -#' -#' \strong{State space form:} -#' -#' The following notation is closest to the one of Koopman et al. The state -#' space model is represented by the transition equation and the measurement -#' equation. Let m be the dimension of the state variable, d be the dimension of -#' the observations, and n the number of observations. The transition equation -#' and the measurement equation are given by \deqn{a(t + 1) = d(t) + T(t) a(t) + -#' H(t) \eta(t)} \deqn{y(t) = c(t) + Z(t) a(t) + G(t) \epsilon(t),} where -#' \eqn{\eta(t)} and \eqn{\epsilon(t)} are iid \eqn{N(0, I_m)} and iid \eqn{N(0, -#' I_d)}, respectively, and \eqn{\alpha(t)} denotes the state variable. The -#' parameters admit the following dimensions: -#' -#' \tabular{lll}{ \eqn{a_t \in R^m}{a[t] in R^m} \tab \eqn{d_t \in R^m}{d[t] in -#' R^m} \tab \eqn{\eta_t \in R^m}{eta[t] in R^m} \cr \eqn{T_t \in R^{m \times -#' m}}{d[t] in R^{m \times m}} \tab \eqn{H_t \in R^{m \times m}}{d[t] in R^{m \times m}} -#' \tab \cr \eqn{y_t \in R^d}{y[t] in R^d} \tab \eqn{c_t \in R^d}{c[t] in R^d} -#' \tab \eqn{\epsilon_t \in R^d}{epsilon[t] in R^d}. \cr \eqn{Z_t \in R^{d -#' \times m}}{Z[t] in R^{d \times m}} \tab \eqn{G_t \in R^{d \times d}}{G[t] in R^{d -#' \times d}} \tab} -#' -#' Note that \code{kalman} takes as input \code{HHt} and \code{GGt} which -#' corresponds to \eqn{H_t H_t'}{H[t] \%*\% t(H[t])} and \eqn{G_t G_t'}{G[t] -#' \%*\% t(G[t])}. -#' -#' \strong{Iteration:} -#' -#' Let \code{i} be the loop variable. The filter iterations are implemented the -#' following way (in case of no NA's): Initialization:\cr \code{if(i == 1)\{}\cr -#' \code{ at[, i] = a0}\cr \code{ Pt[,, i] = P0}\cr \code{\}} -#' -#' Updating equations:\cr \code{vt[, i] = yt[, i] - ct[, i] - Zt[,,i] \%*\% at[, -#' i]}\cr \code{Ft[,, i] = Zt[,, i] \%*\% Pt[,, i] \%*\% t(Zt[,, i]) + GGt[,, -#' i]}\cr \code{Kt[,, i] = Pt[,, i] \%*\% t(Zt[,, i]) \%*\% solve(Ft[,, i])}\cr -#' \code{att[, i] = at[, i] + Kt[,, i] \%*\% vt[, i]}\cr \code{Ptt[, i] = Pt[,, -#' i] - Pt[,, i] \%*\% t(Zt[,, i]) \%*\% t(Kt[,, i])} -#' -#' Prediction equations:\cr \code{at[, i + 1] = dt[, i] + Tt[,, i] \%*\% att[, -#' i]}\cr \code{Pt[,, i + 1] = Tt[,, i] \%*\% Ptt[,, i] \%*\% t(Tt[,, i]) + -#' HHt[,, i]} -#' -#' Next iteration:\cr \code{i <- i + 1}\cr goto \dQuote{Updating equations}. -#' -#' -#' \strong{Parameters:} -#' -#' The parameters can either be constant or deterministic time-varying. Assume -#' the number of observations is \eqn{n} (i.e. \eqn{y = (y_t)_{t = 1, \ldots, -#' n}, y_t = (y_{t1}, \ldots, y_{td})}{y = y[,1:n]}). Then, the parameters admit -#' the following classes and dimensions: \tabular{ll}{ \code{dt} \tab either a -#' \eqn{m \times n}{m * n} (time-varying) or a \eqn{m \times 1}{m * 1} -#' (constant) matrix. \cr \code{Tt} \tab either a \eqn{m \times m \times n}{m * -#' m * n} or a \eqn{m \times m \times 1}{m * m * 1} array. \cr \code{HHt} \tab -#' either a \eqn{m \times m \times n}{m * m * n} or a \eqn{m \times m \times -#' 1}{m * m * 1} array. \cr \code{ct} \tab either a \eqn{d \times n}{d * n} or a -#' \eqn{d \times 1}{d * 1} matrix. \cr \code{Zt} \tab either a \eqn{d \times m -#' \times n}{d * m * n} or a \eqn{d \times m \times 1}{d * m * 1} array. \cr -#' \code{GGt} \tab either a \eqn{d \times d \times n}{d * d * n} or a \eqn{d -#' \times d \times 1}{d * d * 1} array. \cr \code{yt} \tab a \eqn{d \times n}{d -#' * n} matrix. } -#' -#' \strong{Output:} -#' -#' The output values are the filter estimates, smoother estimates, -#' associated forecasts, and the negative log likelihood. -#' -#' \describe{ -#' \item {\code{at}}{One step ahead expectation of the hidden state} -#' \item {\code{Pt}{One step ahead variance of the hidden state} -#' \item {\code{preds}}{One step ahead forecast of the observation} -#' \item {\code{ahat}}{Smoothed state mean (conditional on all data)} -#' \item {\code{att}}{State expectation given information up to time t} -#' \item {\code{Ptt}}{State variance given information up to time t} -#' \item {\code{ests}}{Smoothed forecast (conditionall on all data)} -#' \item {\code{llik}}{log likelihood (not negative)} -#' } -#' -#' @examples -#' data(tempos) -#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, -#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, -#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) -#' y = matrix(tempos[,'Richter_1976'], 1) -#' lt = diff(c(tempos$note_onset, 61)) -#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], -#' c(132,0), c(400,10)) # prior means and variances on X_1 -#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, -#' HHt, GGt, y, transMat, 200)) -#' bestpath = with(beam, paths[which.max(weights),]) -#' kal = kalman(pmats, bestpath, y) -#' -#' @export -kalman <- function(pmats, path, y) { - .Call('_dpf_kalman', PACKAGE = 'dpf', pmats, path, y) -} - +# Generated by using Rcpp::compileAttributes() -> do not edit by hand +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#' @export +resampleSubOptimal <- function(w, N) { + .Call('_dpf_resampleSubOptimal', PACKAGE = 'dpf', w, N) +} + +#' @export +resampleOptimal <- function(w, N) { + .Call('_dpf_resampleOptimal', PACKAGE = 'dpf', w, N) +} + +#' Fast likelihood evaluation given parameters and discrete states +#' +#' This function quickly computes the (negative) log likelihood for a possibly +#' time varying state-space model. The goal is to enable ML (or Bayesian) estimation +#' of parameters without extra computational overhead +#' +#' @param pmats a list of parameter matrices for the kalman filter. +#' This can either be the output of \code{\link{musicModel}}, or a list with +#' the same names as the output of \code{\link{musicModel}}. This list must contain +#' the following elements: \code{a0, P0, dt, ct, Tt, Zt, HHt, GGt}. See the details below. +#' @param path vector giving the path for hidden discrete states +#' @param y observations, each time point in a column +#' +#' @return the negative log-likelihood +#' +#' @details +#' \describe{ +#' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} +#' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} +#' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} +#' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} +#' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} +#' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} +#' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} +#' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} +#' } +#' +#' @examples +#' data(tempos) +#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#' y = matrix(tempos[,'Richter_1976'], 1) +#' lt = diff(c(tempos$note_onset, 61)) +#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) # prior means and variances on X_1 +#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, +#' HHt, GGt, y, transMat, 200)) +#' bestpath = with(beam, paths[which.max(weights),]) +#' getloglike(pmats, bestpath, y) +#' +#' @export +getloglike <- function(pmats, path, y) { + .Call('_dpf_getloglike', PACKAGE = 'dpf', pmats, path, y) +} + +#' Parameter matrices for our music model +#' +#' This function accepts a number of parameters and creates a list of matrices +#' for Kalman filter evaluation. See the paper for the particular form of the model. +#' +#' @param lt vector of durations between successive notes in the score +#' @param sig2eps variance of the observation noise +#' @param mus vector of 3 mean parameters (\eqn{\mu, \tau, and \varphi}) +#' @param sig2eta vector of 3 state variance parameters (\eqn{\sigma_3^2, \sigma_2^2,and \sigma_4^2}) +#' @param transprobs vector of 7 transition probabilities +#' @param initialMean a vector of length 2 giving the prior tempo and the prior acceleration for when state 1 or 3 is the starting state +#' @param initialVariance a vector of length 2 giving the prior variance for the tempo and the prior variance for the acceleration for when state 1 or 3 is the starting state +#' +#' @return List with components as appropriate for Kalman filtering or Beam Search. These include: \describe{ +#' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} +#' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} +#' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} +#' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} +#' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} +#' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} +#' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} +#' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} +#' \item{transMat}{a dxd matrix of transition probabilities for the discrete states} +#' } +#' +#' @examples +#' data(tempos) +#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#' y = matrix(tempos[,'Richter_1976'], 1) +#' lt = diff(c(tempos$note_onset, 61)) +#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) +#' +#' @export +musicModel <- function(lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance) { + .Call('_dpf_musicModel', PACKAGE = 'dpf', lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance) +} + +#' Parameter matrices for our music model on dynamics +#' +#' This function accepts a number of parameters and creates a list of matrices +#' for Kalman filter evaluation. See the paper for the particular form of the model. +#' +#' @param lt vector of durations between successive notes in the score +#' @param sig2eps variance of the observation noise +#' @param mus vector of 3 mean parameters (\eqn{\mu, \tau, and \varphi}) +#' @param sig2eta vector of 3 state variance parameters (\eqn{\sigma_3^2, \sigma_2^2,and \sigma_4^2}) +#' @param transprobs vector of 7 transition probabilities +#' @param initialMean a vector of length 2 giving the prior tempo and the prior acceleration for when state 1 or 3 is the starting state +#' @param initialVariance a vector of length 2 giving the prior variance for the tempo and the prior variance for the acceleration for when state 1 or 3 is the starting state +#' +#' @return List with components as appropriate for Kalman filtering or Beam Search. These include: \describe{ +#' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} +#' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} +#' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} +#' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} +#' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} +#' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} +#' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} +#' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} +#' \item{transMat}{a dxd matrix of transition probabilities for the discrete states} +#' } +#' +#' @examples +#' data(tempos) +#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#' y = matrix(tempos[,'Richter_1976'], 1) +#' lt = diff(c(tempos$note_onset, 61)) +#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) +#' +#' @export +musicModeldynamics <- function(lt, mueps, sig2eps, mus, sig2eta, transprobs, muerror, initialMean, initialVariance) { + .Call('_dpf_musicModeldynamics', PACKAGE = 'dpf', lt, mueps, sig2eps, mus, sig2eta, transprobs, muerror, initialMean, initialVariance) +} + +#' Greedy HMM estimation given continuous hidden states +#' +#' This function maintains a "beam" of size \code{N} representing the highest likelihood +#' states up to time \code{t}. For a typical switching state space model, ML evaluation +#' requires computing each of the \code{d^N} possible paths through the discrete +#' state space. Beam Search greedily approximates these computations be propagating +#' the most likely states at each time point. +#' +#' @param a0 a pxd matrix of state prior means, where the i'th column is the mean for the i'th state +#' @param P0 a (p^2)xd state prior covariance matrix, where the i'th column is the covariance matrix stored columnwise for the i'th state +#' @param w0 a vector specifying the prior probability of starting in each of the d discrete states +#' @param dt a pxdxn (or pxdx1 if all n slices are the same) cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i. +#' @param ct a kxdxn (or kxdx1 if all n slices are the same) cube of observation intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i. +#' @param Tt a (p^2)xdxn (or (p^2)xdx1 if all n slices are the same) cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i. +#' @param Zt a pkxdxn (or pkxdx1 if all n slices are the same) cube of obvervation slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i. +#' @param HHt a (p^2)xdxn (or (p^2)xdx1 if all n slices are the same) cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i. +#' @param GGt a (k^2)xdxn (or kxdx1 if all n slices are the same) cube of observation covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i. +#' @param yt a kxn matrix of obervations +#' @param transProbs a dxd matrix of transition probabilities for the discrete states +#' @param N the maximum particle number +#' @param samplemethod is the method in which the resampling stage should be performed. A "0" indicates that low probability particles should be resampled with equal probability. A "1" indicates that only the large "N" particles with the largest probabilities will be kept. +#' +#' @return List with components "paths", "weights", and "LastStep". +#' \describe{ +#' \item{"paths"}{is an Nxn matrix specifying the paths of each particle,} +#' \item{"weights"}{is a vector giving the final sampling weight of each path,} +#' \item{"LastStep"}{is the timestep computed. "LastStep" will alway equal n unless all of the sampling weights vanish.} +#' } +#' +#' @examples +#' data(tempos) +#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#' y = matrix(tempos[,'Richter_1976'], 1) +#' lt = diff(c(tempos$note_onset, 61)) +#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) # prior means and variances on X_1 +#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, +#' HHt, GGt, y, transMat, 200, samplemethod = 1)) +#' +#' @export +beamSearch <- function(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N, samplemethod) { + .Call('_dpf_beamSearch', PACKAGE = 'dpf', a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N, samplemethod) +} + +#' Estimate continuous states given parameters and discrete hidden states +#' +#' Performs Kalman filtering and smoothing for the switching state space model. +#' Also works on any (potentially time varying) state space model. +#' +#' @param pmats a list with componente \code{a0, P0, dt, ct, Tt, Zt, HHt,} and \code{GGt} +#' e.g., as output from musicModel. See the details below. +#' @param path path of discrete hidden states +#' @param y observations +#' +#' @return List with components from Kalman filter and Smoother. See details. +#' +#' @details +#' +#' \strong{State space form:} +#' +#' The following notation is closest to the one of Koopman et al. The state +#' space model is represented by the transition equation and the measurement +#' equation. Let m be the dimension of the state variable, d be the dimension of +#' the observations, and n the number of observations. The transition equation +#' and the measurement equation are given by \deqn{a(t + 1) = d(t) + T(t) a(t) + +#' H(t) \eta(t)} \deqn{y(t) = c(t) + Z(t) a(t) + G(t) \epsilon(t),} where +#' \eqn{\eta(t)} and \eqn{\epsilon(t)} are iid \eqn{N(0, I_m)} and iid \eqn{N(0, +#' I_d)}, respectively, and \eqn{\alpha(t)} denotes the state variable. The +#' parameters admit the following dimensions: +#' +#' \tabular{lll}{ \eqn{a_t \in R^m}{a[t] in R^m} \tab \eqn{d_t \in R^m}{d[t] in +#' R^m} \tab \eqn{\eta_t \in R^m}{eta[t] in R^m} \cr \eqn{T_t \in R^{m \times +#' m}}{d[t] in R^{m \times m}} \tab \eqn{H_t \in R^{m \times m}}{d[t] in R^{m \times m}} +#' \tab \cr \eqn{y_t \in R^d}{y[t] in R^d} \tab \eqn{c_t \in R^d}{c[t] in R^d} +#' \tab \eqn{\epsilon_t \in R^d}{epsilon[t] in R^d}. \cr \eqn{Z_t \in R^{d +#' \times m}}{Z[t] in R^{d \times m}} \tab \eqn{G_t \in R^{d \times d}}{G[t] in R^{d +#' \times d}} \tab} +#' +#' Note that \code{kalman} takes as input \code{HHt} and \code{GGt} which +#' corresponds to \eqn{H_t H_t'}{H[t] \%*\% t(H[t])} and \eqn{G_t G_t'}{G[t] +#' \%*\% t(G[t])}. +#' +#' \strong{Iteration:} +#' +#' Let \code{i} be the loop variable. The filter iterations are implemented the +#' following way (in case of no NA's): Initialization:\cr \code{if(i == 1)\{}\cr +#' \code{ at[, i] = a0}\cr \code{ Pt[,, i] = P0}\cr \code{\}} +#' +#' Updating equations:\cr \code{vt[, i] = yt[, i] - ct[, i] - Zt[,,i] \%*\% at[, +#' i]}\cr \code{Ft[,, i] = Zt[,, i] \%*\% Pt[,, i] \%*\% t(Zt[,, i]) + GGt[,, +#' i]}\cr \code{Kt[,, i] = Pt[,, i] \%*\% t(Zt[,, i]) \%*\% solve(Ft[,, i])}\cr +#' \code{att[, i] = at[, i] + Kt[,, i] \%*\% vt[, i]}\cr \code{Ptt[, i] = Pt[,, +#' i] - Pt[,, i] \%*\% t(Zt[,, i]) \%*\% t(Kt[,, i])} +#' +#' Prediction equations:\cr \code{at[, i + 1] = dt[, i] + Tt[,, i] \%*\% att[, +#' i]}\cr \code{Pt[,, i + 1] = Tt[,, i] \%*\% Ptt[,, i] \%*\% t(Tt[,, i]) + +#' HHt[,, i]} +#' +#' Next iteration:\cr \code{i <- i + 1}\cr goto \dQuote{Updating equations}. +#' +#' +#' \strong{Parameters:} +#' +#' The parameters can either be constant or deterministic time-varying. Assume +#' the number of observations is \eqn{n} (i.e. \eqn{y = (y_t)_{t = 1, \ldots, +#' n}, y_t = (y_{t1}, \ldots, y_{td})}{y = y[,1:n]}). Then, the parameters admit +#' the following classes and dimensions: \tabular{ll}{ \code{dt} \tab either a +#' \eqn{m \times n}{m * n} (time-varying) or a \eqn{m \times 1}{m * 1} +#' (constant) matrix. \cr \code{Tt} \tab either a \eqn{m \times m \times n}{m * +#' m * n} or a \eqn{m \times m \times 1}{m * m * 1} array. \cr \code{HHt} \tab +#' either a \eqn{m \times m \times n}{m * m * n} or a \eqn{m \times m \times +#' 1}{m * m * 1} array. \cr \code{ct} \tab either a \eqn{d \times n}{d * n} or a +#' \eqn{d \times 1}{d * 1} matrix. \cr \code{Zt} \tab either a \eqn{d \times m +#' \times n}{d * m * n} or a \eqn{d \times m \times 1}{d * m * 1} array. \cr +#' \code{GGt} \tab either a \eqn{d \times d \times n}{d * d * n} or a \eqn{d +#' \times d \times 1}{d * d * 1} array. \cr \code{yt} \tab a \eqn{d \times n}{d +#' * n} matrix. } +#' +#' \strong{Output:} +#' +#' The output values are the filter estimates, smoother estimates, +#' associated forecasts, and the negative log likelihood. +#' +#' \describe{ +#' \item {\code{at}}{One step ahead expectation of the hidden state} +#' \item {\code{Pt}{One step ahead variance of the hidden state} +#' \item {\code{preds}}{One step ahead forecast of the observation} +#' \item {\code{ahat}}{Smoothed state mean (conditional on all data)} +#' \item {\code{att}}{State expectation given information up to time t} +#' \item {\code{Ptt}}{State variance given information up to time t} +#' \item {\code{ests}}{Smoothed forecast (conditionall on all data)} +#' \item {\code{llik}}{log likelihood (not negative)} +#' } +#' +#' @examples +#' data(tempos) +#' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#' y = matrix(tempos[,'Richter_1976'], 1) +#' lt = diff(c(tempos$note_onset, 61)) +#' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) # prior means and variances on X_1 +#' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, +#' HHt, GGt, y, transMat, 200)) +#' bestpath = with(beam, paths[which.max(weights),]) +#' kal = kalman(pmats, bestpath, y) +#' +#' @export +kalman <- function(pmats, path, y) { + .Call('_dpf_kalman', PACKAGE = 'dpf', pmats, path, y) +} + diff --git a/R/musicfuns.R b/R/musicfuns.R index ab39fd9..a84c6ea 100644 --- a/R/musicfuns.R +++ b/R/musicfuns.R @@ -18,6 +18,27 @@ convert10to4 <- function(path){ path10 } +#' Converts from the 0,1,2,3 to 1,2,3,4 notation +#' +#' +#' @param path path in four-state form +#' +#' @return path in two-state form +#' +#' @examples +#' path = sample(1:10, 25, replace=TRUE) +#' npath = convert10to4(path) +#' +#' @export +convertdynamicstates <- function(path){ + t1 = c(1,2,3,4) + path10 = t1[path+1] + path10 +} + + + + # Deprecated -------------------------------------------------------------- diff --git a/R/plots.R b/R/plots.R index 6e3b93d..b8ebf63 100644 --- a/R/plots.R +++ b/R/plots.R @@ -52,3 +52,128 @@ plotStates <- function(performance, params, y, onset, legend.title = ggplot2::element_blank()) + ggplot2::ggtitle(performance) } + + +#' Plots the Music Model states and Kalman smoothed estimates +#' +#' @param theta parameters in same order +#' +#' @param states vector of states at each time period (not converted) +#' +#' @param y vector of tempos or dynamics of a single performance +#' +#' @param onset vector of onsets. +#' +#' @param model If using the dynamics model put "dynamics". If using the tempo model put "tempo". +#' +#' @param priormean Prior Mean array +#' +#' @param priorvar Prior Variance array +#' +#' @param title Change the title of the plot +#' +#' @return A plot showing the estimated values of the kalman smoother along with the states. +#' +#' @examples +#'theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, +#' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, +#' 0.43966082, 0.02116317, 0.24513563, 0.17253254) +#'y = matrix(tempos[,'Richter_1976'], 1) +#'lt = diff(c(tempos$note_onset, 61)) +#'pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], +#' c(132,0), c(400,10)) # prior means and variances on X_1 +#'beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, +#' HHt, GGt, y, transMat, 200)) +#'states = beam$paths[which.max(beam$weights),] +#' +#'plotStates2(theta,states,y,tempos$note_onset,model="tempo",c(132,0),c(400,10),title="Richter 1976") +#' +#' +#'theta = c(20,10, +#' 12,13,14, +#' 21,22,23, +#' .3,.2,.1,.5) +#'y = matrix(dynamics[,'Richter_1976'], 1) +#'lt = diff(c(dynamics$note_onset, 61)) +#' +#'pmats = musicModeldynamics(lt, theta[1], theta[2], theta[3:5], theta[6:8], theta[9:12], c(20,0,0), c(25,10,0)) +#'beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, +#' HHt, GGt, y, transMat, 200)) +#'states = beam$paths[which.max(beam$weights),] +#'kal <- kalman(pmats,states,y) +#'plotStates2(theta,states,y,dynamics$note_onset,model="dynamics",c(20,0,0), c(25,10,0),title="Richter 1976") +#' +#' @export +plotStates2 <- function(theta, states, y, onset, model, priormean, priorvar, title="Music Plot"){ + lt = diff(c(onset,61)) + + if(model=="dynamics"){ + mats = musicModeldynamics(lt, theta[1], theta[2], theta[3:5], theta[6:8], theta[9:12], theta[13], + priormean, priorvar) + kal <- kalman(mats,states,y) + df = data.frame( + measure = onset, + dynamics = c(y), + inferred = c(kal$ests), + state = factor( + states, + levels=c(0,1,2,3), + labels=c('New Value', 'Smooth Progression','Loud Deviation','Soft Deviation') + ) + ) + df2 <- data.frame( + start = c(0,9,17,21,33,45,53), + end = c(8,16,20,32,44,52,60)+1, + direction = factor(c(1,0,2,0,4,1,0), + levels=c(0,1,2,4), + labels=c("p","f","ff","poco piu vivo")) + ) + myplot <- ggplot2::ggplot(df) + + geom_rect(data=df2, aes(NULL,NULL,xmin=start,xmax=end,fill=direction), + ymin=-Inf,ymax=Inf,color="white",size=0.5,alpha=0.3)+ + scale_fill_manual("Composer Direction",values=c("p"="grey95", + "f"="grey90", + "ff"="grey75", + "sf"="grey50", + "poco piu vivo"="lightblue"))+ + ggplot2::geom_line(ggplot2::aes(x=measure, y=dynamics), color='grey10') + + ggplot2::geom_point(ggplot2::aes(x=measure, y=inferred, color=state)) + + scale_color_manual("Performer Intention",values=c('New Value'="blue", + 'Smooth Progression'="darkcyan", + 'Loud Deviation'="darkorange1", + 'Soft Deviation'="red"))+ + ggplot2::theme(legend.position = 'right') + + ggplot2::ggtitle(title) + + cowplot::theme_cowplot() + + ggplot2::labs(x="Measure", y="Dynamics") + } + + if(model=="tempo"){ + mats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], + priormean, priorvar) + kal <- kalman(pmats,states,y) + df = data.frame( + measure = onset, + tempo = c(y), + inferred = c(kal$ests), + state = factor( + convert10to4(states), + levels=c(1,2,3,4), + labels=c('constant tempo', 'decelerating','accelerating','stress') + ) + ) + myplot <- ggplot2::ggplot(df) + + ggplot2::geom_rect( + data=data.frame(xmin = 33, xmax = 45, ymin = -Inf, ymax = Inf), + mapping=ggplot2::aes(xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax), + fill = 'gray90', color = 'gray90') + + ggplot2::geom_line(ggplot2::aes(x=measure, y=tempo), color='black') + + ggplot2::geom_point(ggplot2::aes(x=measure, y=inferred, color=state)) + + ggplot2::scale_color_brewer(palette = 'Paired') + + ggplot2::theme_minimal() + + ggplot2::theme(legend.position = 'bottom', + legend.title = ggplot2::element_blank()) + + ggplot2::ggtitle(title) + } + return(myplot) +} diff --git a/dpf-master.Rproj b/dpf-master.Rproj new file mode 100644 index 0000000..8d82f1f --- /dev/null +++ b/dpf-master.Rproj @@ -0,0 +1,17 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/extras/cluster_analysis_my_model.R b/extras/cluster_analysis_my_model.R index 7b3c5d7..214abdd 100644 --- a/extras/cluster_analysis_my_model.R +++ b/extras/cluster_analysis_my_model.R @@ -1,22 +1,22 @@ -# 1. This file estimates parameters for all performances in parallel using -# a cluster. See https://mllg.github.io/batchtools/ for setup instructions -# to run on your own machine or an appropriate managed HPC system. -# Note that, as specified, each performance takes around 5 hours on my laptop. - -library(dpf) -library(batchtools) -library(dplyr) -library(optimr) # cran version -# library(optimrx) # dev version (installed on my laptop) -# Note: optimrx correctly handles inability to find an optimum within multistart(), optimr does not -# fix is to add badval=1e8 to the control list, see optimizer() in djm_optimization.R - -data(tempos) -lt = diff(c(tempos$note_onset,61)) -source("my_model.R") -makeRegistry("my-mazurka", packages=c('dpf','optimr'), - source = "my_model.R", - seed = 20181109) -batchMap(optimizer, as.list(select(tempos, -meas_num, -note_onset, -beat)), - more.args = list(lt=lt)) -#submitJobs(resources = list(ppn=1, nodes=1, memory='16gb', walltime='24:00:00')) +# 1. This file estimates parameters for all performances in parallel using +# a cluster. See https://mllg.github.io/batchtools/ for setup instructions +# to run on your own machine or an appropriate managed HPC system. +# Note that, as specified, each performance takes around 5 hours on my laptop. + +library(dpf) +library(batchtools) +library(dplyr) +library(optimr) # cran version +# library(optimrx) # dev version (installed on my laptop) +# Note: optimrx correctly handles inability to find an optimum within multistart(), optimr does not +# fix is to add badval=1e8 to the control list, see optimizer() in djm_optimization.R + +data(tempos) +lt = diff(c(tempos$note_onset,61)) +source("my_model.R") +makeRegistry("my-mazurka", packages=c('dpf','optimr'), + source = "my_model.R", + seed = 20181109) +batchMap(optimizer, as.list(select(tempos, -meas_num, -note_onset, -beat)), + more.args = list(lt=lt)) +#submitJobs(resources = list(ppn=1, nodes=1, memory='16gb', walltime='24:00:00')) diff --git a/extras/cluster_analysis_my_model_dynamics.R b/extras/cluster_analysis_my_model_dynamics.R new file mode 100644 index 0000000..5c1fcb4 --- /dev/null +++ b/extras/cluster_analysis_my_model_dynamics.R @@ -0,0 +1,22 @@ +# 1. This file estimates parameters for all performances in parallel using +# a cluster. See https://mllg.github.io/batchtools/ for setup instructions +# to run on your own machine or an appropriate managed HPC system. +# Note that, as specified, each performance takes around 5 hours on my laptop. + +library(dpf) +library(batchtools) +library(dplyr) +library(optimr) # cran version +# library(optimrx) # dev version (installed on my laptop) +# Note: optimrx correctly handles inability to find an optimum within multistart(), optimr does not +# fix is to add badval=1e8 to the control list, see optimizer() in djm_optimization.R + +data(dynamics) +lt = diff(c(tempos$note_onset,61)) +source("my_model_dynamics.R") +makeRegistry("my-mazurka-dynamics", packages=c('dpf','optimr'), + source = "my_model_dynamics.R", + seed = 20200405) +batchMap(optimizer, as.list(select(dynamics, -meas_num, -note_onset, -beat)), + more.args = list(lt=lt)) +submitJobs(resources = list(ppn=1, nodes=1, memory='16gb', walltime='48:00:00')) diff --git a/extras/collect_cluster_results_dynamics.R b/extras/collect_cluster_results_dynamics.R new file mode 100644 index 0000000..f604e5e --- /dev/null +++ b/extras/collect_cluster_results_dynamics.R @@ -0,0 +1,15 @@ +#2. This short script collects all parameter estimates from the cluster +# (or local) when run via cluster_analysis_my_model.R + +library(batchtools) +loadRegistry('my-mazurka-dynamics', writeable=TRUE) + +getStatus() + +outL = reduceResultsList() +fun = function(x) x[which.min(x$value),] +pvec_ml = t(sapply(outL,fun)) +rownames(pvec_ml) = names(dynamics[-c(1:3)]) +pvec_ml = as.data.frame(pvec_ml) + +save(pvec_ml, file='mazurkaDynamicsResults.Rdata') diff --git a/extras/mazurkaDynamicsResults.Rdata b/extras/mazurkaDynamicsResults.Rdata new file mode 100644 index 0000000..b555e07 Binary files /dev/null and b/extras/mazurkaDynamicsResults.Rdata differ diff --git a/extras/mazurkaDynamicsResultsOLD1.Rdata b/extras/mazurkaDynamicsResultsOLD1.Rdata new file mode 100644 index 0000000..eaa929f Binary files /dev/null and b/extras/mazurkaDynamicsResultsOLD1.Rdata differ diff --git a/extras/mazurkaDynamicsResultsOLD2.Rdata b/extras/mazurkaDynamicsResultsOLD2.Rdata new file mode 100644 index 0000000..1ec8019 Binary files /dev/null and b/extras/mazurkaDynamicsResultsOLD2.Rdata differ diff --git a/extras/my-mazurka-dynamics/more.args.rds b/extras/my-mazurka-dynamics/more.args.rds new file mode 100644 index 0000000..b83a0f1 Binary files /dev/null and b/extras/my-mazurka-dynamics/more.args.rds differ diff --git a/extras/my-mazurka-dynamics/registry.rds b/extras/my-mazurka-dynamics/registry.rds new file mode 100644 index 0000000..b92afe2 Binary files /dev/null and b/extras/my-mazurka-dynamics/registry.rds differ diff --git a/extras/my-mazurka-dynamics/results/1.rds b/extras/my-mazurka-dynamics/results/1.rds new file mode 100644 index 0000000..2f4b3f9 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/1.rds differ diff --git a/extras/my-mazurka-dynamics/results/10.rds b/extras/my-mazurka-dynamics/results/10.rds new file mode 100644 index 0000000..cd75a48 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/10.rds differ diff --git a/extras/my-mazurka-dynamics/results/11.rds b/extras/my-mazurka-dynamics/results/11.rds new file mode 100644 index 0000000..eff95ec Binary files /dev/null and b/extras/my-mazurka-dynamics/results/11.rds differ diff --git a/extras/my-mazurka-dynamics/results/12.rds b/extras/my-mazurka-dynamics/results/12.rds new file mode 100644 index 0000000..37fd8a0 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/12.rds differ diff --git a/extras/my-mazurka-dynamics/results/13.rds b/extras/my-mazurka-dynamics/results/13.rds new file mode 100644 index 0000000..cbf48a7 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/13.rds differ diff --git a/extras/my-mazurka-dynamics/results/14.rds b/extras/my-mazurka-dynamics/results/14.rds new file mode 100644 index 0000000..1b49b08 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/14.rds differ diff --git a/extras/my-mazurka-dynamics/results/15.rds b/extras/my-mazurka-dynamics/results/15.rds new file mode 100644 index 0000000..df0ecdc Binary files /dev/null and b/extras/my-mazurka-dynamics/results/15.rds differ diff --git a/extras/my-mazurka-dynamics/results/16.rds b/extras/my-mazurka-dynamics/results/16.rds new file mode 100644 index 0000000..3e429d4 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/16.rds differ diff --git a/extras/my-mazurka-dynamics/results/17.rds b/extras/my-mazurka-dynamics/results/17.rds new file mode 100644 index 0000000..36ffe70 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/17.rds differ diff --git a/extras/my-mazurka-dynamics/results/18.rds b/extras/my-mazurka-dynamics/results/18.rds new file mode 100644 index 0000000..992ff40 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/18.rds differ diff --git a/extras/my-mazurka-dynamics/results/19.rds b/extras/my-mazurka-dynamics/results/19.rds new file mode 100644 index 0000000..e08d016 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/19.rds differ diff --git a/extras/my-mazurka-dynamics/results/2.rds b/extras/my-mazurka-dynamics/results/2.rds new file mode 100644 index 0000000..11df740 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/2.rds differ diff --git a/extras/my-mazurka-dynamics/results/20.rds b/extras/my-mazurka-dynamics/results/20.rds new file mode 100644 index 0000000..b9241de Binary files /dev/null and b/extras/my-mazurka-dynamics/results/20.rds differ diff --git a/extras/my-mazurka-dynamics/results/21.rds b/extras/my-mazurka-dynamics/results/21.rds new file mode 100644 index 0000000..42adbdc Binary files /dev/null and b/extras/my-mazurka-dynamics/results/21.rds differ diff --git a/extras/my-mazurka-dynamics/results/22.rds b/extras/my-mazurka-dynamics/results/22.rds new file mode 100644 index 0000000..29a03db Binary files /dev/null and b/extras/my-mazurka-dynamics/results/22.rds differ diff --git a/extras/my-mazurka-dynamics/results/23.rds b/extras/my-mazurka-dynamics/results/23.rds new file mode 100644 index 0000000..af851c8 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/23.rds differ diff --git a/extras/my-mazurka-dynamics/results/24.rds b/extras/my-mazurka-dynamics/results/24.rds new file mode 100644 index 0000000..4345ac3 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/24.rds differ diff --git a/extras/my-mazurka-dynamics/results/25.rds b/extras/my-mazurka-dynamics/results/25.rds new file mode 100644 index 0000000..45e4534 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/25.rds differ diff --git a/extras/my-mazurka-dynamics/results/26.rds b/extras/my-mazurka-dynamics/results/26.rds new file mode 100644 index 0000000..4e99746 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/26.rds differ diff --git a/extras/my-mazurka-dynamics/results/27.rds b/extras/my-mazurka-dynamics/results/27.rds new file mode 100644 index 0000000..18d9e13 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/27.rds differ diff --git a/extras/my-mazurka-dynamics/results/28.rds b/extras/my-mazurka-dynamics/results/28.rds new file mode 100644 index 0000000..8bd69cc Binary files /dev/null and b/extras/my-mazurka-dynamics/results/28.rds differ diff --git a/extras/my-mazurka-dynamics/results/29.rds b/extras/my-mazurka-dynamics/results/29.rds new file mode 100644 index 0000000..4248acb Binary files /dev/null and b/extras/my-mazurka-dynamics/results/29.rds differ diff --git a/extras/my-mazurka-dynamics/results/3.rds b/extras/my-mazurka-dynamics/results/3.rds new file mode 100644 index 0000000..0366a22 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/3.rds differ diff --git a/extras/my-mazurka-dynamics/results/30.rds b/extras/my-mazurka-dynamics/results/30.rds new file mode 100644 index 0000000..773497d Binary files /dev/null and b/extras/my-mazurka-dynamics/results/30.rds differ diff --git a/extras/my-mazurka-dynamics/results/31.rds b/extras/my-mazurka-dynamics/results/31.rds new file mode 100644 index 0000000..4286e3a Binary files /dev/null and b/extras/my-mazurka-dynamics/results/31.rds differ diff --git a/extras/my-mazurka-dynamics/results/32.rds b/extras/my-mazurka-dynamics/results/32.rds new file mode 100644 index 0000000..df607d3 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/32.rds differ diff --git a/extras/my-mazurka-dynamics/results/33.rds b/extras/my-mazurka-dynamics/results/33.rds new file mode 100644 index 0000000..6873299 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/33.rds differ diff --git a/extras/my-mazurka-dynamics/results/34.rds b/extras/my-mazurka-dynamics/results/34.rds new file mode 100644 index 0000000..477d40d Binary files /dev/null and b/extras/my-mazurka-dynamics/results/34.rds differ diff --git a/extras/my-mazurka-dynamics/results/35.rds b/extras/my-mazurka-dynamics/results/35.rds new file mode 100644 index 0000000..a6d6749 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/35.rds differ diff --git a/extras/my-mazurka-dynamics/results/36.rds b/extras/my-mazurka-dynamics/results/36.rds new file mode 100644 index 0000000..8bdebb9 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/36.rds differ diff --git a/extras/my-mazurka-dynamics/results/37.rds b/extras/my-mazurka-dynamics/results/37.rds new file mode 100644 index 0000000..1384046 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/37.rds differ diff --git a/extras/my-mazurka-dynamics/results/38.rds b/extras/my-mazurka-dynamics/results/38.rds new file mode 100644 index 0000000..f3402e1 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/38.rds differ diff --git a/extras/my-mazurka-dynamics/results/39.rds b/extras/my-mazurka-dynamics/results/39.rds new file mode 100644 index 0000000..7dad5e1 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/39.rds differ diff --git a/extras/my-mazurka-dynamics/results/4.rds b/extras/my-mazurka-dynamics/results/4.rds new file mode 100644 index 0000000..1c79df0 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/4.rds differ diff --git a/extras/my-mazurka-dynamics/results/40.rds b/extras/my-mazurka-dynamics/results/40.rds new file mode 100644 index 0000000..9a9a9ff Binary files /dev/null and b/extras/my-mazurka-dynamics/results/40.rds differ diff --git a/extras/my-mazurka-dynamics/results/41.rds b/extras/my-mazurka-dynamics/results/41.rds new file mode 100644 index 0000000..2adb432 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/41.rds differ diff --git a/extras/my-mazurka-dynamics/results/42.rds b/extras/my-mazurka-dynamics/results/42.rds new file mode 100644 index 0000000..1418ca5 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/42.rds differ diff --git a/extras/my-mazurka-dynamics/results/43.rds b/extras/my-mazurka-dynamics/results/43.rds new file mode 100644 index 0000000..b8d0000 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/43.rds differ diff --git a/extras/my-mazurka-dynamics/results/44.rds b/extras/my-mazurka-dynamics/results/44.rds new file mode 100644 index 0000000..e70057a Binary files /dev/null and b/extras/my-mazurka-dynamics/results/44.rds differ diff --git a/extras/my-mazurka-dynamics/results/45.rds b/extras/my-mazurka-dynamics/results/45.rds new file mode 100644 index 0000000..b7e0edd Binary files /dev/null and b/extras/my-mazurka-dynamics/results/45.rds differ diff --git a/extras/my-mazurka-dynamics/results/46.rds b/extras/my-mazurka-dynamics/results/46.rds new file mode 100644 index 0000000..2dc6fe8 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/46.rds differ diff --git a/extras/my-mazurka-dynamics/results/5.rds b/extras/my-mazurka-dynamics/results/5.rds new file mode 100644 index 0000000..0ed526e Binary files /dev/null and b/extras/my-mazurka-dynamics/results/5.rds differ diff --git a/extras/my-mazurka-dynamics/results/6.rds b/extras/my-mazurka-dynamics/results/6.rds new file mode 100644 index 0000000..ad4babd Binary files /dev/null and b/extras/my-mazurka-dynamics/results/6.rds differ diff --git a/extras/my-mazurka-dynamics/results/7.rds b/extras/my-mazurka-dynamics/results/7.rds new file mode 100644 index 0000000..d049bc3 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/7.rds differ diff --git a/extras/my-mazurka-dynamics/results/8.rds b/extras/my-mazurka-dynamics/results/8.rds new file mode 100644 index 0000000..6024bbe Binary files /dev/null and b/extras/my-mazurka-dynamics/results/8.rds differ diff --git a/extras/my-mazurka-dynamics/results/9.rds b/extras/my-mazurka-dynamics/results/9.rds new file mode 100644 index 0000000..6a56888 Binary files /dev/null and b/extras/my-mazurka-dynamics/results/9.rds differ diff --git a/extras/my-mazurka-dynamics/user.function.rds b/extras/my-mazurka-dynamics/user.function.rds new file mode 100644 index 0000000..5bab58b Binary files /dev/null and b/extras/my-mazurka-dynamics/user.function.rds differ diff --git a/extras/my_model_dynamics.R b/extras/my_model_dynamics.R new file mode 100644 index 0000000..bf67308 --- /dev/null +++ b/extras/my_model_dynamics.R @@ -0,0 +1,100 @@ +# Source file for prior and likelihood functions. Not needed separately. + +logprior <- function(theta,yt){ + p2s = c(theta[9],1-sum(theta[c(9,10,11)]),theta[c(10,11)]) + p2 = ddirichlet(p2s, alpha=c(5,85,5,5),log=TRUE) + p4 = dbeta(theta[12],2,8, log=TRUE) + muc = dgamma(theta[1], shape=100, scale=.1, log = TRUE) + sig2eps = dgamma(theta[2], shape=10, scale=.5, log = TRUE) + mu0 = dnorm(theta[3], mean(yt), sd=10, log = TRUE) + mu1 = dnorm(theta[4], 0, sd=.25, log = TRUE) + mu2 = dnorm(theta[5], 0, sd=.25, log = TRUE) + sig0 = dgamma(theta[6], shape=10, scale=1, log=TRUE) + sig1 = dgamma(theta[7], shape=3, scale=1, log=TRUE) + sig2 = dgamma(theta[8], shape=3, scale=1, log=TRUE) + mue = dgamma(-theta[13], shape=100, scale=.1, log = TRUE) + lp = sum(muc, sig2eps, mu0, mu1, mu2, sig0, sig1, sig2, + p2, p4, mue) + lp +} + +prior_means <- function(yt){ + c(10, 5, + mean(yt), 0, 0, + 10, 3, 3, + 0.05,0.05,.05,0.2, + -10) +} + +rprior <- function(n,yt){ + muc = rgamma(n, shape=100, scale=.1) + sig2eps = rgamma(n, shape=10, scale=.5) + mu0 = rnorm(n, mean=mean(yt), sd = 10) + mu1 = rnorm(n, mean=0, sd = .25) + mu2 = rnorm(n, mean=0, sd = .25) + sig0 = rgamma(n, shape=10, scale=1) + sig1 = rgamma(n, shape=3, scale=1) + sig2 = rgamma(n, shape=3, scale=1) + p2 = rdirichlet(n, alpha=c(5,85,5,5)) + p21 = p2[1] + p23 = p2[3] + p24 = p2[4] + p41 = rbeta(n,2,8) + mue = -rgamma(n, shape=100, scale=.1) + cbind(muc, sig2eps, mu0, mu1, mu2, sig0, sig1, sig2, + p21, p23, p24, p41, mue) +} + + + +logStatesGivenParams <- function(states,transProbs){ + ind = cbind(states[1:(length(states)-1)], states[2:length(states)]) + 1 + return(sum(log(transProbs[ind]))) +} + + +toOptimize <- function(theta, yt, lt, Npart, badvals=Inf){ + if(any(theta[c(2,6:8)]<0)){ + cat('do not allow negative variance') + return(badvals) + } + pmats = musicModeldynamics(lt, theta[1], theta[2], theta[3:5], theta[6:8], theta[9:12], theta[13], + c(18,0,0), + c(10,2,2)) + beam = beamSearch(pmats$a0, pmats$P0, c(1,0,0,0), + pmats$dt, pmats$ct, pmats$Tt, pmats$Zt, + pmats$HHt, pmats$GGt, yt, pmats$transMat, Npart, samplemethod = 1) + if(beam$LastStep < length(lt)){ + cat('beam$LastStep < length(lt)\n') + return(badvals) + } + if(all(is.na(beam$weights))){ + cat('all weights are NA\n') + return(badvals) + } + states = beam$paths[which.max(beam$weights),] + negllike = getloglike(pmats, states, yt)# -log(P(y|params, states)) + sgp = -1 * logStatesGivenParams(states, pmats$transMat) + logp = -1 * logprior(theta,yt) + obj = negllike + logp + sgp + obj +} + + +# Cluster funs ------------------------------------------------------------ + +optimizer <- function(perf, lt, Npart=500, ntries = 10, badvals=1e8){ + yt = matrix(perf, nrow=1) + randos = NULL + if(ntries > 1) randos = rprior(ntries-1,yt) + init_vals = rbind(prior_means(yt), randos) + out1 = multistart(init_vals, toOptimize, yt=yt, lt=lt, Npart=Npart, + badvals=badvals, + method='Nelder-Mead', + control=list(trace=0, maxit=5000, badval=badvals)) + out2 = multistart(init_vals, toOptimize, yt=yt, lt=lt, Npart=Npart, + badvals=badvals, + method='SANN', + control=list(trace=0, maxit=5000,badval=badvals)) + out = rbind.data.frame(out1, out2) +} diff --git a/man/beamSearch.Rd b/man/beamSearch.Rd index 8504115..4019ff9 100644 --- a/man/beamSearch.Rd +++ b/man/beamSearch.Rd @@ -4,7 +4,21 @@ \alias{beamSearch} \title{Greedy HMM estimation given continuous hidden states} \usage{ -beamSearch(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N) +beamSearch( + a0, + P0, + w0, + dt, + ct, + Tt, + Zt, + HHt, + GGt, + yt, + transProbs, + N, + samplemethod +) } \arguments{ \item{a0}{a pxd matrix of state prior means, where the i'th column is the mean for the i'th state} @@ -30,6 +44,8 @@ beamSearch(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N) \item{transProbs}{a dxd matrix of transition probabilities for the discrete states} \item{N}{the maximum particle number} + +\item{samplemethod}{is the method in which the resampling stage should be performed. A "0" indicates that low probability particles should be resampled with equal probability. A "1" indicates that only the large "N" particles with the largest probabilities will be kept.} } \value{ List with components "paths", "weights", and "LastStep". @@ -56,6 +72,6 @@ lt = diff(c(tempos$note_onset, 61)) pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], c(132,0), c(400,10)) # prior means and variances on X_1 beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, - HHt, GGt, y, transMat, 200)) + HHt, GGt, y, transMat, 200, samplemethod = 1)) } diff --git a/man/convertdynamicstates.Rd b/man/convertdynamicstates.Rd new file mode 100644 index 0000000..060008c --- /dev/null +++ b/man/convertdynamicstates.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/musicfuns.R +\name{convertdynamicstates} +\alias{convertdynamicstates} +\title{Converts from the 0,1,2,3 to 1,2,3,4 notation} +\usage{ +convertdynamicstates(path) +} +\arguments{ +\item{path}{path in four-state form} +} +\value{ +path in two-state form +} +\description{ +Converts from the 0,1,2,3 to 1,2,3,4 notation +} +\examples{ +path = sample(1:10, 25, replace=TRUE) +npath = convert10to4(path) + +} diff --git a/man/dpf.Rd b/man/dpf.Rd index f2252b9..b9a5f9d 100644 --- a/man/dpf.Rd +++ b/man/dpf.Rd @@ -3,7 +3,6 @@ \docType{package} \name{dpf} \alias{dpf} -\alias{dpf-package} \title{dpf: Discrete particle filtering} \description{ The dpf package provides three categories of important functions: diff --git a/man/kalman.Rd b/man/kalman.Rd index 76e1bd4..1d799ac 100644 --- a/man/kalman.Rd +++ b/man/kalman.Rd @@ -20,6 +20,9 @@ List with components from Kalman filter and Smoother. See details. \description{ Performs Kalman filtering and smoothing for the switching state space model. Also works on any (potentially time varying) state space model. +} +\details{ + } \examples{ data(tempos) diff --git a/man/musicModel.Rd b/man/musicModel.Rd index 0d3834c..e443b73 100644 --- a/man/musicModel.Rd +++ b/man/musicModel.Rd @@ -4,8 +4,7 @@ \alias{musicModel} \title{Parameter matrices for our music model} \usage{ -musicModel(lt, sig2eps, mus, sig2eta, transprobs, initialMean, - initialVariance) +musicModel(lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance) } \arguments{ \item{lt}{vector of durations between successive notes in the score} diff --git a/man/musicModeldynamics.Rd b/man/musicModeldynamics.Rd new file mode 100644 index 0000000..e0c9966 --- /dev/null +++ b/man/musicModeldynamics.Rd @@ -0,0 +1,60 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{musicModeldynamics} +\alias{musicModeldynamics} +\title{Parameter matrices for our music model on dynamics} +\usage{ +musicModeldynamics( + lt, + mueps, + sig2eps, + mus, + sig2eta, + transprobs, + initialMean, + initialVariance +) +} +\arguments{ +\item{lt}{vector of durations between successive notes in the score} + +\item{sig2eps}{variance of the observation noise} + +\item{mus}{vector of 3 mean parameters (\eqn{\mu, \tau, and \varphi})} + +\item{sig2eta}{vector of 3 state variance parameters (\eqn{\sigma_3^2, \sigma_2^2,and \sigma_4^2})} + +\item{transprobs}{vector of 7 transition probabilities} + +\item{initialMean}{a vector of length 2 giving the prior tempo and the prior acceleration for when state 1 or 3 is the starting state} + +\item{initialVariance}{a vector of length 2 giving the prior variance for the tempo and the prior variance for the acceleration for when state 1 or 3 is the starting state} +} +\value{ +List with components as appropriate for Kalman filtering or Beam Search. These include: \describe{ +\item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} +\item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} +\item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} +\item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} +\item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} +\item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} +\item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} +\item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} +\item{transMat}{a dxd matrix of transition probabilities for the discrete states} +} +} +\description{ +This function accepts a number of parameters and creates a list of matrices +for Kalman filter evaluation. See the paper for the particular form of the model. +} +\examples{ +data(tempos) +theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, + 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, + 0.43966082, 0.02116317, 0.24513563, 0.17253254) +y = matrix(tempos[,'Richter_1976'], 1) +lt = diff(c(tempos$note_onset, 61)) +pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], + c(132,0), c(400,10)) + +} diff --git a/man/plotStates.Rd b/man/plotStates.Rd index 4b647f7..a6f91af 100644 --- a/man/plotStates.Rd +++ b/man/plotStates.Rd @@ -4,8 +4,15 @@ \alias{plotStates} \title{Plots the observed tempo and estimated discrete states given parameters.} \usage{ -plotStates(performance, params, y, onset, particleNumber = 200, - initialMean = c(132, 0), initialVariance = c(400, 10)) +plotStates( + performance, + params, + y, + onset, + particleNumber = 200, + initialMean = c(132, 0), + initialVariance = c(400, 10) +) } \arguments{ \item{performance}{The named performance, e.g. 'Richter_1976'. See \code{names(tempos)}.} diff --git a/man/plotStates2.Rd b/man/plotStates2.Rd new file mode 100644 index 0000000..a43605a --- /dev/null +++ b/man/plotStates2.Rd @@ -0,0 +1,70 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plots.R +\name{plotStates2} +\alias{plotStates2} +\title{Plots the Music Model states and Kalman smoothed estimates} +\usage{ +plotStates2( + theta, + states, + y, + onset, + model, + priormean, + priorvar, + title = "Music Plot" +) +} +\arguments{ +\item{theta}{parameters in same order} + +\item{states}{vector of states at each time period (not converted)} + +\item{y}{vector of tempos or dynamics of a single performance} + +\item{onset}{vector of onsets.} + +\item{model}{If using the dynamics model put "dynamics". If using the tempo model put "tempo".} + +\item{priormean}{Prior Mean array} + +\item{priorvar}{Prior Variance array} + +\item{title}{Change the title of the plot} +} +\value{ +A plot showing the estimated values of the kalman smoother along with the states. +} +\description{ +Plots the Music Model states and Kalman smoothed estimates +} +\examples{ +theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, + 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, + 0.43966082, 0.02116317, 0.24513563, 0.17253254) +y = matrix(tempos[,'Richter_1976'], 1) +lt = diff(c(tempos$note_onset, 61)) +pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], + c(132,0), c(400,10)) # prior means and variances on X_1 +beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, y, transMat, 200)) +states = beam$paths[which.max(beam$weights),] + +plotStates2(theta,states,y,tempos$note_onset,model="tempo",c(132,0),c(400,10),title="Richter 1976") + + +theta = c(20,10, + 12,13,14, + 21,22,23, + .3,.2,.1,.5) +y = matrix(dynamics[,'Richter_1976'], 1) +lt = diff(c(dynamics$note_onset, 61)) + +pmats = musicModeldynamics(lt, theta[1], theta[2], theta[3:5], theta[6:8], theta[9:12], c(20,0,0), c(25,10,0)) +beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, y, transMat, 200)) +states = beam$paths[which.max(beam$weights),] +kal <- kalman(pmats,states,y) +plotStates2(theta,states,y,dynamics$note_onset,model="dynamics",c(20,0,0), c(25,10,0),title="Richter 1976") + +} diff --git a/manuscript/dynamicspaper/Dynamics-Model.Rmd b/manuscript/dynamicspaper/Dynamics-Model.Rmd new file mode 100644 index 0000000..9ea1a64 --- /dev/null +++ b/manuscript/dynamicspaper/Dynamics-Model.Rmd @@ -0,0 +1,593 @@ +--- +title: Switching State Space Models for Interpreting Musical Dynamics + +# to produce blinded version set to 1 +blinded: 0 + +authors: +- name: Robert Granger + affiliation: Department of Statistics, Indiana University + + +keywords: +- classical music +- hidden Markov model + +abstract: | + In this paper, we attempt to illuminate a performer's musical intentions using a Markov-switching state space model. Specifically, the model we propose is designed for the dynamics of classical music. Unlike many other models of trend estimation, this model requires the estimation of a series of parameters. These parameters can be viewed as hidden musical attributes of a performance that would not be revealed through the calculation of simple statistics. For this analysis, we use dynamics data of 46 different performances of Chopin’s Mazurka Op. 68 No. 3. from the Centre for the History and Analysis of Recorded Music (CHARM) Mazurka Project. + + + +bibliography: musicdynamicsbib.bib +bibliostyle: unsrtnat +header-includes: + - \usepackage{booktabs} + - \usepackage{pgf} + - \usepackage{tikz} + - \usepackage[ruled,vlined]{algorithm2e} + - \usepackage[toc,page]{appendix} + - \usepackage{longtable} + - \hypersetup{ + colorlinks=true, + linkcolor=red, + citecolor = blue, + urlcolor=cyan, + } + - \newcommand*{\Appendixautorefname}{appendix} + - \usepackage{float} #use the 'float' package + - \floatplacement{figure}{t} + - \usepackage[skip=0pt]{caption} + +output: rticles::asa_article +--- + +\def\algorithmautorefname{Algorithm} + +```{r codesetup, warning=FALSE, message=FALSE, echo=FALSE} +library(dpf) +library(ggplot2) +library(knitr) +library(tidyverse) +library(cowplot) +library(kableExtra) + +load("mazurkaDynamicsResults.Rdata") +thetatable <- as.data.frame(t(do.call(rbind.data.frame, pvec_ml[,1:13]))) +thetatable <- thetatable[order(row.names(thetatable)),] #sorts by performance (alphabetical) + +perftitle <- sub("_", " ", rownames(thetatable)) #Remove underscore +perftitle <- sub("\\.", "-", perftitle) #Change . to - + +roundthetatable <- round(thetatable,2) +parameters1 <- roundthetatable[1:23,c(1,13,2:8)] +parameters2 <- roundthetatable[24:46,c(1,13,2:8)] +probabilities1 <- roundthetatable[1:23,9:12] +probabilities2 <- roundthetatable[24:46,9:12] + +mysymbolsparam <- c("$\\mu_c$","$\\mu_e$","$\\sigma^2_\\epsilon$","$\\mu_0$","$\\mu_1$","$\\mu_2$","$\\sigma^2_0$","$\\sigma^2_1$","$\\sigma^2_2$") +mysymbolsprobs <- c("$p_{21}$","$p_{23}$","$p_{24}$","$p_{41}$") + +roundthetatable3 <- round(thetatable,3) +``` + + + +# Introduction + + +In this paper, we attempt to illuminate a performer's musical intentions surrounding the dynamics of classical music. Through the use of a Markov-switching state space model, the series of dynamics values within a single performance are carefully smoothed with the goal of differentiating the perceived intentions of the performer from the observed dynamics found in the data. Classical music is different from other types of music as a composer creates a piece, but many performers may play it adding their own interpretation. While, the composer gives some specific direction like the pitch of notes to play, the instructions regarding dynamics are relatively vague. For example, when performing a piece, a performer will observe a \emph{p} which stands for \emph{piano}, indicating this section should be played "softly". Meanwhile, an \emph{f} stands for \emph{forte} and indicates the given section should be played "loudly". While we would expect the \emph{forte} section to be played louder than the \emph{piano} section, no direction is given on how softly or loudly the specified section should be played. The performer may also attempt to ease into a \emph{piano} section from a \emph{forte} section or they may want to make a sudden change. These decisions are left to the interpretation of the performer. + +There are a variety of different trend estimating techniques, but we propose using a Markov-switching state space model for two reasons. First, the technique should incorporate actions found within a performance. Often times, performers make dramatic changes in dynamics to start a new section, something we want our model to identify, not smooth out as noise. Likewise, this may extend to individual notes where intentional emphasis is used by the performer. Using smoothing techniques like a moving average or spline would ignore these key elements. The second reason for using this type of model is that it requires the estimation of certain parameters. These parameters offer additional insight and can be viewed as hidden attributes of a performance. Attributes found through simple calculation of averages and variances would ignore the complexity of the decisions made during a performance. + +Similar analysis of modelling musical performances with Markov-switching state space models has been performed on tempo data \citep{mcdonald_markov-switching_2019,gu_modeling_2012}. When modeling tempo, the expectation is for the performer to hold a constant tempo, with some periods of potential speeding up or slowing down. This same expectation cannot be said for the dynamics and thus requires a different model setup. Although a Markov-switching state space model can still be used, the difference comes in the selection of different discrete states and parameter matrices. While Gu and Raphael did give some attention to modeling dynamics, this paper looks to expand their work. + +\def\sectionautorefname{Section} + +The paper procedes as follows: \autoref{Sec:model} begins with a general description of Markov-switching state space models followed with specific details regarding the states and the parameter matrices used to model musical dynamics. \autoref{sec:analysis} explains the algorithm used to evaluate the model and discusses results for several performances. \autoref{sec:conclusion} briefly concludes with potential uses of this model along with potential future areas of research. + + +\section{The Markov-Switching State Space Model} +\label{Sec:model} + +State space models are commonly used to model time series observations in the presence of hidden, continuous states. As a result of the state space framework, the observations are viewed as independent conditional on the hidden states whereas these hidden states will follow a vector autoregressive process. Adding assumptions of linearity and normal error produces what is commonly referred to as the general linear Gaussian state space model \citep{durbin_time_2012}. It takes the form +\begin{equation} + \begin{aligned} + y_t &= C_t + D_tx_t + \epsilon_t, + & \epsilon_t & \sim N(0,G_t)\\ + x_{t+1} &= A_t + B_tx_t + \eta_t, + & \eta_t & \sim N(0,H_t), + & x_1 & \sim N(x_0,P_0) \\ + \end{aligned} + \label{eq:statespacemod} +\end{equation} +where the first part of \autoref{eq:statespacemod} is known as the observation equation and the second part is known as the state equation. The vector $y_t$ consists of the known observations at each time period, $t$, whereas the vector $x_t$ consists of the unobserved, continuous states on which $y_t$ is dependent. The observation error, $\epsilon_t$, and the state equation error, $\eta_t$, are assumed to be serially independent and independent of each other. + +In the typical state space framework, the matrices $A_t$, $B_t$, $C_t$, $D_t$, $G_t$, and $H_t$ are allowed to vary across time but are known. If there are a finite number of perceived structures for these matrices, and the given structure is unknown at time, $t$, a Markov-switching state space model can be used. This model assumes there are some underlying discrete states, $s_t$, that transition over time through a Markov process. Making this slight adjustment to \autoref{eq:statespacemod} yields the following model which will be used as a basic framework for modeling music dynamics. + +\begin{equation} + \begin{aligned} + y_t &= C_t(s_t) + D_t(s_t)x_t + \epsilon_t, + & \epsilon_t & \sim N(0,G_t)\\ + x_{t+1} &= A_t(s_t) + B_t(s_t)x_t + \eta_t, + & \eta_t & \sim N(0,H_t), + & x_1 & \sim N(x_0,P_0) \\ + \end{aligned} + \label{eq:switchstatemodel} +\end{equation} + +When it comes to musical dynamics, rarely do musicians attempt to play with the same dynamics or loudness throughout the entirety of a piece. Most of the time we expect the musician to steadily change the loudness from note to note; however, there may exist moments where the musician deviates greatly from the trend with either louder or softer than usual notes. A single note may be played more loudly because the performer is specifically trying to add emphasis. Adding this emphasis may be on the performer's own perogative or may be dictated by the piece with an accent, "\textbf{$>$}". On the other hand, a single note appearing in the data more softly is likely not part of the performer's intent. If a note in the data is played more softly, it may be because the performer missed a note or did not hit it as hard as intended. It could also be something went wrong in the data creation step. Regardless, we do not attempt to identify why the dynamics data indicates an unusually soft note, but it is important to include this in our model for statistical estimation purposes. We tried estimating without explicitly incorporating these low sounds in the model, but the excessive statistical noise caused the model to falsely indicate starts of new smooth progressions. Therefore, in order to model the described behavior, we propose the following four discrete states: + +\begin{list}{}{} + +\item[$s^1$:] The musician selects a new value for loudness. + +\item[$s^2$:] The musician continues the dynamics in a steady way. + +\item[$s^3$:] The musician plays a single note more loudly. + +\item[$s^4$:] The musician plays a single note more softly. + +\end{list} + +The observation, $y_t$ is the univariate loudness of the note at each time period, $t$. In order to allow the dynamics to progress steadily, the continuous hidden states, $x_t$, follow a process that allows for piece-wise quadratics. At each time period, $x_t$, is a vector of length three, +$$x_t^\prime = (x^0_t, x^1_t, x^2_t), $$ +where $x^0_t$ is the loudness, $x^1_t$ is the first order difference, and $x^2_t$ is the second order difference. The aim is to maintain this smooth progression even when the musician plays a single note more loudly or softly. The states $s^3$ and $s^4$ are therefore implemented by adding a constant in the observation equation as opposed to changing the state equation. The model is similar to that proposed in \cite{gu_modeling_2012}, but extended to include these additional states. \autoref{tab:parmats} shows the parameter matrices for the four states. + +\begin{table} +\caption{Parameter matrices for the switching state space model.\label{tab:parmats}} +\centering +\begin{tabular}[h!]{@{}ccccccccc@{}} +\toprule +%&&&\multicolumn{3}{c}{Parameter Matrices}\\ + \multicolumn{2}{c}{States} &\phantom{a}& \multicolumn{6}{c}{Parameter Matrices}\\ + \cmidrule{1-2} \cmidrule{4-9} + \multicolumn{2}{c}{$S$}&& $A$ & $B$ & $C$ & $D$ & $G$ & $H$ \\ + \midrule + \multicolumn{2}{c}{$s^1$} && $\begin{pmatrix} \mu_0 \\ \mu_1 \\ \mu_2 \end{pmatrix}$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$ & 0 & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} \sigma_0^2&0&0 \\ 0&\sigma_1^2&0 \\ 0&0&\sigma_2^2 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^2$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & 0 & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^3$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & $\mu_c$ & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^4$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & $\mu_e$ & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + +\bottomrule +\end{tabular} +\end{table} + +The final part of the switching state space model is designing the Markov process for transitioning between the discrete states which is displayed in \autoref{fig:transmat}. The first state, $s^1$, allows for the selection of a new loudness which then transitions into the smooth progresson state, $s^2$, with probability 1. When arriving in $s^2$, the next time period's discrete state can be any of the possible states including itself. If in this progression, we move to a sudden loud note, $s^3$, or a sudden soft note, $s^4$, then we have the opportunity to continue the smooth progression, $s^2$, or start a new smooth progression, $s^1$. It is not permissible though to immediately then play another sudden loud or soft note. + +In total, there are 13 unknown parameters, $\theta \in \Theta$, spread across 4 different discrete states, $s^i \in S$, through $T$ time periods. A summary of the parameters to be estimated are: $\Theta = \{\mu_c, \mu_e, \sigma^2_\epsilon, \mu_0, \mu_1, \mu_2, \sigma^2_0, \sigma^2_1, \sigma^2_2, p_{21}, p_{23}, p_{24}, p_{41}\}$. Note this vector contains only four probabilities. With four states, the transition matrix could potentially have up to twelve probabilities requiring estimation; however, because of the restrictions placed on the possible transitions, this number is reduced to four. In the next section, we discuss finding smoothed estimates of the dynamics which requires estimation of these parameters along with the continuous and discrete states. + +\begin{figure}[tb!] +\caption{Transition diagram. \label{fig:transmat}} + \centering + \tikzstyle{switch}=[rectangle, + thick, minimum size=1cm, draw=black] + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] + \matrix[row sep=0.25cm,column sep=.5cm] { + &&& \node (S1) [switch] {$s^1$};&&& \\ + \\ \\ \\ \\ \\ \\ + &&& \node (S2) [switch] {$s^2$};&&& \\ + \\ \\ \\ \\ \\ \\ + &\node (S3) [switch] {$s^3$}; &&&& \node (S4) [switch] {$s^4$};\\ + }; + \path[->] + (S1) edge [bend right] node [left] {1}(S2) + (S2) edge [bend right] node [right] {$p_{21}$}(S1) + (S2) edge [loop above] node [left] {}(S2) + (S2) edge [bend right] node [right] {$p_{23}$}(S3) + (S2) edge [bend right] node [right] {$p_{24}$}(S4) + % (S3) edge [bend left] node [left] {$p_{31}$}(S1) + (S3) edge [bend right] node [left] {1}(S2) + (S4) edge [bend right] node [right] {$p_{41}$}(S1) + (S4) edge [bend right] node [left] {}(S2); + \end{tikzpicture} +\end{figure} + + + +\section{Evaluating the Model} +\label{sec:analysis} + +Evaluation of the model requires the estimation of the parameters, $\theta \in \Theta$; the discrete states, $\{s_t\}^T_{t=1}$; and the continuous hidden states $\{x_t\}^T_{t=1}$. These estimates are obtained using only the assumptions and structure of the model along with the observed dynamics, $\{y_t\}^T_{t=1}$. Once these estimates are obtained, we then compute predicted values, $E[y_t|...]$, which can be thought of as the performer's intended dynamics. Hence, the aim in estimating the intended dynamics is attempting to remove $\epsilon_t$, which can be seen as unintended deviations from the desired loudness. + +\subsection{The Algorithm} + +When the parameter values, $\theta_i \in \Theta$, and the discrete states, $\{s_t\}^T_{t=1}$, are known, the Kalman filter \citep{kalman_new_1960} can be used to find estimates of the continuous hidden states, $\{x_t\}_{t=1}^T$, along with the likelihood. While the Kalman filter provides an easy way to compute the likelihood, the estimate of $x_t$ is obtained using only observations coming before time $t$. In order to use all information, we implement the Kalman smoothing algorithm introduced in \citep{rauch_maximum_1965}. This algorithm provides an estimate, $\hat{x_t} = E[x_t|y_1,...y_T]$, which can be used to compute a fitted or "smoothed" value, $\hat{y_t}$. + +The Kalman smoother provides a closed form solution to obtaining the maximum likelihood estimates of our continuous hidden states, but what if the discrete states, $\{s_t\}^T_{t=1}$, are unknown? We can obtain the most likely set of discrete states by simply running the Kalman smoother algorithm on every possible combination of discrete states and choosing the set of discrete states that yields the largest likelihood. This may work if the number of discrete states and/or time periods is small; however, the number of state combinations to check may be large and can be computed as $|\{s^i \in S\}|^T$. For example, the music dynamics model presented in the previous section has four discrete states and the piece to be evaluated, Chopin's Mazurka Op.\ 68 No.\ 3, has 231 notes. This brings the grand total of state combinations to check to $4^{231}\approx1.19\times 10^{139}$. Of course, many of these state combinations could be removed due to 0 likelihood given the restrictions on the state transitions, but even with this taken into account, the number of state combinations is far too large. To overcome this issue, we use the Discrete Particle Filter as described in \cite{mcdonald_markov-switching_2019}. We begin by estimating the partial likelihood iteratively through time at each of the possible discrete state paths using the Kalman Filter. Each of these paths is known as a particle with only the previous states and partial likelihood being saved. This process would still require checking all $|\{s^i \in S\}|^T$ paths, so to get around this, we implement the greedy search algorithm called Beam Search. This search algorithm requires selecting a maximum number of particles to save at each time iteration and discards the rest. + +\begin{figure}[tb!] + \centering + \tikzstyle{switch}=[rectangle, + thick, minimum size=0.5cm, draw=black] + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] + \matrix[row sep=0.25cm,column sep=.75cm] { + \node (S1) [switch] {$s_1$}; &&\node (S4) [switch] {$s_1s_1$};&& \node (S7) [switch] {$s_1s_1$}; && \node (S8) [switch] {$s_1s_1s_1$}; && \node (S9) [switch] {$s_1s_1s_1$}; &&\\ + \\ + && && && \node (S13) [switch] {$s_1s_1s_2$};\\ + \\ + &&\node (S3) [switch] {$s_1s_2$}; && \node (S10) [switch] {$s_1s_2$}; && \node (S14) [switch] {$s_1s_2s_1$}; && \node (S20) [switch] {$s_1s_2s_1$}; \\ + \\ + && && && \node (S15) [switch] {$s_1s_2s_2$}; && \node (S21) [switch] {$s_2s_2s_2$}; \\ + \\ + \node (S2) [switch] {$s_2$}; &&\node (S5) [switch] {$s_2s_1$};&&\node (S11) [switch] {$s_2s_1$};&& \node (S16) [switch] {$s_2s_1s_1$}; && \node (S22) [switch] {$s_2s_1s_1$}; \\ + \\ + && && && \node (S17) [switch] {$s_2s_1s_2$};&&\node (S23) [switch] {$s_2s_1s_2$}; + \\ + &&\node (S6) [switch] {$s_2s_2$};&&\node (S12) [switch] {$s_2s_2$};&& \node (S18) [switch] {$s_2s_2s_1$};\\ + \\ + &&&&&& \node (S19) [switch] {$s_2s_2s_2$}; &&\\ + \\ + \hline + \\ + \\ + $t=1$ && && \hspace{12px} $t=2$ && && \hspace{52px} $t=3$ \\ + }; + \path[->] + (S1) edge (S3) + (S7) edge (S8) + (S7) edge (S13) + (S8) edge [dashed] (S9) + (S10) edge (S14) + (S10) edge (S15) + (S11) edge (S16) + (S11) edge (S17) + (S4) edge [dashed] (S7) + (S1) edge (S4) + (S2) edge (S5) + (S12) edge (S18) + (S12) edge (S19) + (S3) edge [dashed] (S10) + (S5) edge [dashed] (S11) + (S6) edge [dashed] (S12) + (S14) edge [dashed] (S20) + (S15) edge [dashed] (S21) + (S16) edge [dashed] (S22) + (S17) edge [dashed] (S23) + (S2) edge (S6); + \end{tikzpicture} + \caption{Discrete Particle Filter with 2 discrete states and capping the maximum number of stored particles at 5 for each time iteration. \label{fig:dpf}} +\end{figure} + +\autoref{fig:dpf} illustrates this concept with 2 discrete states and the maximum number of particles set at 5. There are four possible state paths to check when passing from $t=1$ to $t=2$ which is less than the maximum particle number so all four paths are saved. When moving from $t=2$ to $t=3$, the number of paths increases to 8. Since only 5 paths are allowed, three of these paths must be dropped and will no longer be considered as possible solutions. In order to decide which paths are to be saved a sampling procedure must be performed. One sampling procedure proposed by \citep{tugnait_detection_1982} is to simply keep the paths that have the highest likelihood. Another sampling procedure proposed by \citep{akashi_random_1977} is to randomly sample one particle out of the total number of states descended from each of the $t-1$ particles in proportion to their respective likelihoods. \citep{fearnhead_-line_2003} proposes another stochastic approach but one that minimizes the expected mean squared error between the approximated distribution and the true distribution's probabilities. This approach determines a threshold value such that all particles with likelihood above this value are kept and the remaining particles to be kept are chosen at random with probability equal to their respective likelihoods. Once a sampling technique is selected and the procedure is implemented through all time points, a sample of discrete state sequences is saved the size of the beam width. Since the goal of this paper is to find the most likely sequence of discrete states, the one with the highest likelihood is selected. + +\begin{algorithm}[t] + \caption{Solving Music Dynamics Model\label{alg:masteralgorithm}} +\SetAlgoLined + \textbf{Input} Y, a vector of observed dynamics\; + \textbf{Initialize} $\Theta$\; + \While{(Stopping Criteria)}{ + Create Matrices A, B, C, D, G, H at each $t$ for each $s^i \in S$\; + Implement Discrete Particle Filter\; + Compute the log-likelihood: \hspace{2px} $l(Y|\Theta,S) + l(S|\Theta) + l(\Theta)$\; + Update $\Theta$ via Nelder-Mead Optimization or SANN\; + } +\end{algorithm} + +The final step is estimating the model parameters, $\Theta$, that maximize the likelihood. This is a difficult task as this model presents a couple of problems: 1) many of the parameters are constrained as variances need to be positive and the probabilities of leaving the same state should sum to 1 while also being constrained between 0 and 1; 2) there are many local maxima making finding a global maxima difficult. To help alleviate these concerns, we can include Bayesian priors on our parameters. Using carefully selected priors allows us to steer the algorithm away from impossible solutions and direct it toward more desired solutions. These issues also lead us to carefully consider our optimization technique. We will use two different methods. The first is the Nelder-Mead algorithm which can find local maxima for unconstrained multidimensional problems without the need for derivative computation \citep{nelder_simplex_1965}. The second is the Simulated Annealing (SANN) algorithm which is commonly used when dealing with problems with many local maxima in order to estimate the global maxima. Neither of these methods are perfect at avoiding a local maximum and hence the selection of initial values plays an important role. To overcome this challenge, we will select a variety of different starting points drawn randomly from the Bayesian priors. + +\vspace{10px} + +\autoref{alg:masteralgorithm} displays the complete procedure. The solution to this model was found using software R \citep{r_core_team_r_2019}. The Nelder-Mead and SANN methods are performed using the package \texttt{optimr} by \cite{nash_optimr_2019}. The discrete particle filter was implemented by extending the package \texttt{dpf} by \cite{mcdonald_dpf_2020}. + +\subsection{Results for Chopin's Mazurka Op.\ 68 No.\ 3} + +\begin{table}[t] + \caption{Informative prior distributions for Chopin's Mazurka Op.\ 68 No.\ 3} + \centering + \begin{tabular}{@{}rcll@{}} + \toprule + Parameter & \phantom{a} & Distribution & Prior Mean \\ + \midrule + $\mu_c$ & $\sim$ & Gamma$(100,\ 0.1)$ & 10\\ + $\mu_e$ & $\sim$ & -Gamma$(100,\ 0.1)$ & -10\\ + $\sigma^2_{\epsilon}$ & $\sim$ & Gamma$(10,\ 0.5)$ & 5\\ + $\mu_{0}$ & $\sim$ & Normal$(\overline{Y},\ 10)$ & $\overline{Y}$\\ + $\mu_{1} $ & $\sim$ & Normal$(0,\ 0.25)$ & 0\\ + $\mu_{2} $ & $\sim$ & Normal$(0,\ 0.25)$ & 0\\ + $\sigma^2_{0} $ & $\sim$ & Gamma$(10,\ 1)$ & 10 \\ + $\sigma^2_{1} $ & $\sim$ & Gamma$(3,\ 1)$ & 3 \\ + $\sigma^2_{2} $ & $\sim$ & Gamma$(3,\ 1)$ & 3 \\ + $p_{2,\cdot}$ & $\sim$ & Dirichlet$(5,\ 85,\ 5,\ 5)$ & 0.05, 0.85, 0.05, 0.05 \\ + % $p_{3,\cdot}$ & $\sim$ & Beta$(2,\ 8)$ & 0.20\\ + $p_{4,\cdot}$ & $\sim$ & Beta$(2,\ 8)$ & 0.20\\ + \bottomrule + \end{tabular} + \label{tab:priors} +\end{table} + +The model was estimated using observed dynamics from forty-six different performances of Chopin's Mazurka Op.\ 68 No.\ 3. This data was reverse conducted (created) by Craig Sapp using Andrew Earis's Expression Algorithm software. The software and data can be found on the website for the Centre for the History and Analysis of Recorded Music (CHARM) Mazurka Project \citep{charm_centre_2009}. The technique used to create the data is described in detail in Andrew Earis's paper "An algorithm to extra expressive timing and dynamics from piano recordings" \citep{earis_algorithm_2007}. + +To implement \autoref{alg:masteralgorithm} on dynamics data from performances of Chopin's Mazurka Op.\ 68 No.\ 3, we must make a few specific decisons. First, we choose prior distributions applicable specifically to Chopin's Mazurka Op.\ 68 No.\ 3, which can be found in \autoref{tab:priors}. Secondly, regarding the Discrete Particle Filter, we selected to keep up to 500 particles with the sampling criterion of keeping the largest likelihoods. Lastily, since there are many local minima, we used 10 different starting points drawn randomly and independently from each of the prior distributions for each optimization technique (both Nelder-Mead and SANN). + +```{r,exampletable,echo=FALSE,fig.margin=TRUE,fig.cap="\\label{fig:exampletable}Interpreted Dynamics from selected performances of Chopin's Mazurka Op. 68 No. 3. The black line traces the observed dynamics while the colored dots are the smoothed interpreted dynamics.",message=FALSE,warning=FALSE} + + +performance1 <- which(row.names(thetatable)=="Luisada_1991") +performance2 <- which(row.names(thetatable)=="Rubinstein_1966") +performance3 <- which(row.names(thetatable)=="Block_1995") +performance4 <- which(row.names(thetatable)=="Rubinstein_1939") + +theta1 <- as.matrix(thetatable[performance1,],1) +theta2 <- as.matrix(thetatable[performance2,],1) +theta3 <- as.matrix(thetatable[performance3,],1) +theta4 <- as.matrix(thetatable[performance4,],1) + +yt1 <- matrix(dynamics[,'Luisada_1991'], 1) +yt2 <- matrix(dynamics[,'Rubinstein_1966'], 1) +yt3 <- matrix(dynamics[,'Block_1995'], 1) +yt4 <- matrix(dynamics[,'Rubinstein_1939'], 1) +lt = diff(c(dynamics$note_onset, 61)) + +pmats1 = musicModeldynamics(lt, theta1[1], theta1[2], theta1[3:5], theta1[6:8], theta1[9:12], theta1[13], + c(18,0,0), c(10,2,2)) +pmats2 = musicModeldynamics(lt, theta2[1], theta2[2], theta2[3:5], theta2[6:8], theta2[9:12], theta2[13], + c(18,0,0), c(10,2,2)) +pmats3 = musicModeldynamics(lt, theta3[1], theta3[2], theta3[3:5], theta3[6:8], theta3[9:12], theta3[13], + c(18,0,0), c(10,2,2)) +pmats4 = musicModeldynamics(lt, theta4[1], theta4[2], theta4[3:5], theta4[6:8], theta4[9:12], theta4[13], + c(18,0,0), c(10,2,2)) +beam1 = with(pmats1, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, yt1, transMat, 500, samplemethod = 1)) +beam2 = with(pmats2, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, yt2, transMat, 500, samplemethod = 1)) +beam3 = with(pmats3, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, yt2, transMat, 500, samplemethod = 1)) +beam4 = with(pmats4, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, yt2, transMat, 500, samplemethod = 1)) + +states1 = beam1$paths[which.max(beam1$weights),] +states2 = beam2$paths[which.max(beam2$weights),] +states3 = beam3$paths[which.max(beam1$weights),] +states4 = beam4$paths[which.max(beam2$weights),] +kal1 <- kalman(pmats1,states1,yt1) +kal2 <- kalman(pmats2,states2,yt2) +kal3 <- kalman(pmats3,states3,yt3) +kal4 <- kalman(pmats4,states4,yt4) + +dfpart1 <- data.frame(measure = dynamics$note_onset, + dynamics = c(yt1), + inferred = c(kal1$ests), + state = factor(states1, + levels=c(0,1,2,3), + labels=c('New Value', 'Smooth Progression','Loud Deviation','Soft Deviation') + ), + performance = rep("Luisada 1991",231) +) +dfpart2 <- data.frame(measure = dynamics$note_onset, + dynamics = c(yt2), + inferred = c(kal2$ests), + state = factor(states2, + levels=c(0,1,2,3), + labels=c('New Value', 'Smooth Progression','Loud Deviation','Soft Deviation') + ), + performance = rep("Rubinstein 1966",231) +) +dfpart3 <- data.frame(measure = dynamics$note_onset, + dynamics = c(yt3), + inferred = c(kal3$ests), + state = factor(states3, + levels=c(0,1,2,3), + labels=c('New Value', 'Smooth Progression','Loud Deviation','Soft Deviation') + ), + performance = rep("Block 1995",231) +) +dfpart4 <- data.frame(measure = dynamics$note_onset, + dynamics = c(yt4), + inferred = c(kal4$ests), + state = factor(states4, + levels=c(0,1,2,3), + labels=c('New Value', 'Smooth Progression','Loud Deviation','Soft Deviation') + ), + performance = rep("Rubinstein 1939",231) +) +df <- rbind(dfpart1,dfpart2) +#df <- rbind(dfpart1,dfpart2,dfpart3,dfpart4) +df2 <- data.frame(start = c(0,9,17,21,33,45,53), + end = c(8,16,20,32,44,52,60)+1, + direction = factor(c(1,0,2,0,4,1,0), + levels=c(0,1,2,4), + labels=c("p","f","ff","poco piu vivo")) +) + + +myplot <- ggplot2::ggplot(df) + + geom_rect(data=df2, aes(NULL,NULL,xmin=start,xmax=end,fill=direction), + ymin=-Inf,ymax=Inf,color="white",size=0.5,alpha=0.3)+ + scale_fill_manual("Composer Direction",values=c("p"="grey95", + "f"="grey90", + "ff"="grey75", + "sf"="grey50", + "poco piu vivo"="lightblue"))+ + ggplot2::geom_line(ggplot2::aes(x=measure, y=dynamics), color='grey10') + + ggplot2::geom_point(ggplot2::aes(x=measure, y=inferred, color=state)) + + ggplot2::facet_grid(performance~.)+ + scale_color_manual("Performer Intention",values=c('New Value'="blue", + 'Smooth Progression'="darkcyan", + 'Loud Deviation'="darkorange1", + 'Soft Deviation'="red"))+ + ggplot2::theme(legend.position = 'right') + + ggplot2::ggtitle("") + + cowplot::theme_cowplot() + + ggplot2::labs(x="Measure", y="Dynamics")+ + ggplot2::ggtitle("Interpreted Dynamics") +myplot +``` + +Graphical representations for the performances of Jean-Marc Luisada in 1991 and Arthur Rubinstein in 1966 are shown in \autoref{fig:exampletable}. These along with plots of the other forty-four performances can be found in \autoref{appendixd}. The black line traces the observed dynamics for each note across musical time as given by the score. The colored dots are used to differentiate the 4 possible discrete states and show the interpreted musical dynamics for each note. The background is shaded based on musical directions given by the composer in the score. Notice with these performances, the model often seems to start a new smooth progression when the composer gives direction about the dynamics. There are occasions where this is not always the case. Notice that Luisada appears to smoothly adjust the dynamics from the second \emph{piano} section into the \emph{poco piu vivo} section and again when transitioning from the final \emph{forte} section to the final \emph{piano} section. Similarly, Rubinstein also smoothly transitions but he does this between the first \emph{forte} section into the only \emph{fortissimo} section. These unscripted parts of the performance are what we hope to discover as they allow us to contrast and compare each performance. + +```{r table3, echo=FALSE,warning=FALSE,message=FALSE} + +rownames(roundthetatable3) <- sub("_", " ", rownames(roundthetatable3)) #Remove underscore +rownames(roundthetatable3) <- sub("\\.", "-", rownames(roundthetatable3)) #Change . to - + + +performance1 <- which(row.names(roundthetatable3)=="Block 1995") +performance2 <- which(row.names(roundthetatable3)=="Luisada 1991") +performance3 <- which(row.names(roundthetatable3)=="Sofronitsky 1949") +performance4 <- which(row.names(roundthetatable3)=="Rubinstein 1966") +performance5 <- which(row.names(roundthetatable3)=="Grinberg 1951") +performance6 <- which(row.names(roundthetatable3)=="Hatto 1993") +performance7 <- which(row.names(roundthetatable3)=="Richter 1976") + +exampleperformances <- c(performance1,performance2,performance3,performance4,performance5,performance6,performance7) +sortedexampleperformances <- sort(exampleperformances) + +exampleparameters <- roundthetatable3[sortedexampleperformances,c(1,13,2:8)] +exampleprobabilities <- roundthetatable3[sortedexampleperformances,9:12] + + +kable(exampleparameters,format = "latex",booktabs=T,col.names = mysymbolsparam, caption="Parameter Estimates for Selected Performances of Chopin's Mazurka Op.68 No.3\\label{tab:parameterestimatesrichter}", escape=FALSE) %>% + kable_styling(latex_options = "striped") +``` + +```{r table3ext, echo=FALSE,warning=FALSE} +kable(exampleprobabilities,booktabs=T,col.names = mysymbolsprobs, escape=FALSE, + caption="Probability Estimates for Selected Performances of Chopin's Mazurka Op.68 No.3\\label{tab:probestimatesrichter}") %>% + kable_styling(latex_options = "striped") +``` + +Analyzing the graphical representations of each performance have the benefit of illuminating complexities within a performance but may be cumbersome when attempting to compare and contrast many performances. Instead, we analyze the parameter and transition probability values, $\Theta$. All estimated values for the 46 performances can be found in \autoref{appendixa} and \autoref{appendixb}. For the reader's convenience, the parameter estimates for performances discussed in this section can be found in \autoref{tab:parameterestimatesrichter} and \autoref{tab:probestimatesrichter}. Along with the tables of estimated parameters, we also supply density plots of the estimated parameters. These density plots show the distribution of the estimated parameters and should not be mistaken for the estimated posterior distributions for some performance. + +```{r denseplots,echo=FALSE,fig.margin=TRUE,fig.cap="\\label{fig:densityplots}Density Plots of Estimated Parameters for 46 Performances of Chopin's Mazurka Op. 68 No. 3.",message=FALSE,warning=FALSE,fig.height=3.5} + +fixroundthetatable <- roundthetatable[,c(1,13,2:12)] +colnames(fixroundthetatable) <- c("mu[c]","mu[e]","sigma[epsilon]^2","mu[0]","mu[1]","mu[2]","sigma[0]^2","sigma[1]^2","sigma[2]^2", + "p[21]","p[23]","p[24]","p[41]") + +longthetatablemu0and1 <- fixroundthetatable[c(4,5)] %>% + pivot_longer(cols=`mu[0]`:`mu[1]`) + +paramdensitymu0mu1 <- ggplot(longthetatablemu0and1, aes(x=value)) + + geom_density(color="black",fill="lightblue") + + facet_wrap(name~.,nrow=1, scales="free", labeller=label_parsed)+ + theme_cowplot() +paramdensitymu0mu1 +``` + +We analyze the density plots in order to get a better understanding of the distribution of the parameters. We begin with a look at the estimated parameters, $\mu_{0}$ and $\mu_1$. The parameter $\mu_0$ can be interpreted as the most likely starting point for each smoothed quadratic section. Joyce Hatto's 1993 performance is estimated to have the lowest average starting point with $\mu_0=$ `r roundthetatable3[18,3]` and Vladimir Sofronitsky's 1949 performance is estimated to have the highest average starting point with $\mu_0=$ `r roundthetatable[42,3]`. The average of all the $\mu_0$'s across all 46 performances is ```r round(mean(roundthetatable[,3]),3)```. \autoref{fig:densityplots} displays the density plot of $\mu_0$ which reveals the distribution of $\mu_0$'s is fairly symmetric but with more concentration around the mean than the normal distribution. The parameter $\mu_1$ can be interpreted as the average initial change in the dynamics of a performance. As long as $\mu_2$ is small relative to $\mu_1$ or if they both have the same sign, this change will persistent through each smoothed quadratic section. The parameter estimates for these performances range from a low of `r roundthetatable3[33,4]` in Sviatoslav Richter's 1976 performance to a high of `r roundthetatable3[17,4]` in Maria Grinberg's 1951 performance. From the density plot for $\mu_1$, the distribution of the estimated parameters appears roughly normal with a mean equal to ```r round(mean(thetatable$mu1),3)```. The mean being greater than zero indicates that, on average, performers tend to (at least initially) increase the volume through each smoothed quadratic section. + +In order to get a fuller understanding of the parameters, we compare the estimated parameters in Luisada's 1991 performance with Rubinstein's 1966 performance. Luisada's 1991 performance has $\mu_0 = 27.312$, $\mu_1=-0.165$, and $\mu_2=-0.110$ indicating that he typically starts loudly and then softens. On the other hand, Rubinstein's performance has $\mu_0 = 12.840$, $\mu_1=0.470$ and $\mu_2=-0.033$, indicating that he typically starts each smoothed section more softly and then gets louder. Taking an average across all note dynamics for the Luisada 1991 and Rubinstein 1966 performances yields ```r round(mean(dynamics$Luisada_1991),2)``` and ```r round(mean(dynamics$Rubinstein_1966),2)```, respectively. While it is interesting to know that Rubinstein's 1966 was louder, on average, than Luisada's 1991 performance, we can see that without modeling the performer's intentions, interesting details are being missed. We also analyze the variance within each performance. Calculating the overall variation of note dynamics for the Luisada 1996 performance reveals a variance of ```r round(var(dynamics$Luisada_1991),2)```. Calculating the overall note dynamics of the Rubinstein 1996 performance reveals more homogeneity with a variance of ```r round(var(dynamics$Rubinstein_1966),2)```. Although the variation in note dynamics is higher for the Luisada 1996 performance, we observe through modelling the performer's intentions that Luisada typically has less variation in the starting dynamics of each piece-wise quadratic section than Rubinstein with $\sigma^2_0=12.098$ and 17.045, respectively. This is a new characteristic of the performance that would be otherwise hidden without using the music dynamics model. + +Lastly, we compare the four estimated transition probabilities. The estimates for $p_{21}$ and $p_{41}$\footnote{We focus on $p_{21}$ more than $p_{41}$ as being in state 4 is much less likely. } show how likely is it for the performer to start a new smoothed section. The model also reveals how likely the performer will emphasize a note by playing it more loudly through the estimated value $p_{23}$. For the Luisada 1991 and Rubinstein 1966 performances, all of the probabilities are relatively the same, but we do find differences in some of the other performances. For example, while the Luisada 1991 and Rubinstein 1966 performances have relatively low probabilities in starting a new smoothed section, Michel Block's 1995 performance is more likely with $p_{21}=.101$. Also, the Block 1995 performance is more likely to have emphasized notes with estimated $p_{23}=0.027$, a probability larger than either Luisada and Rubinstein's performances. + + +\section{Conclusion} +\label{sec:conclusion} + +Using a Markov-switching state space model, we were able to illuminate the intentions of a classical music performance with regards to the dynamics. In the process, a series of parameters were estimated that can be perceived as musical attributes hidden in the data. Using these attributes, we discussed a few pieces and showed various characteristics that would have been hidden by simply sticking to commonly used statistics like means or standard deviations. We then proceeded to make contrasts and comparisons of the various pieces based on these musical attributes. + +The analysis described here can be taken a step further. In \cite{mcdonald_markov-switching_2019}, the authors chose to cluster the performances based on the estimated parameters from their tempo model using hierarchical clustering. With the estimated parameters here and/or combining them with the estimated parameters of their tempo model, one could use their favorite clustering or classifying techniques on the performances. With additional knowledge from the data, it seems likely that the ability to cluster or classify would be improved. + +Clustering and classifying are the foundational methods used in music recommendation systems that many users of music media platforms rely in order to discover or find new music. For example, the fast growing online music streaming service, Spotify, has a "Made For You" section that creates recommended playlists for the user based on their listening habits. In order to provide these recommendations, Spotify's algorithm takes into consideration information about which songs you "like", "share", and even "skip" along with information from other users that are deemed similar \citep{spotify_spotify_2019}. While it is certainly advantageous to use data from users experience, more information can be obtained by focusing on the musical attributes of a performance itself. Pandora, another music streaming service, created the Music Genome Project where a team of musicologists listen and analyze music in order to assign 450 musical attributes \citep{pandora_music_2020}. These 450 "genes" allow the streaming company to classify or cluster musical pieces in order to make recommendations to its users. It would be interesting to see if and how these additional parameters can improve the ability to classify performances and ultimately create better musical recommendation systems. + + + + + + + +\newpage + +\appendix +\appendixpage +\addappheadtotoc + +\section{Estimates of Parameters for each Performance} +\label{appendixa} + +```{r, echo=FALSE,warning=FALSE,message=FALSE, fig.height=8.5} +roundthetatable <- round(thetatable,2) +rownames(roundthetatable) <- sub("_", " ", rownames(roundthetatable)) #Remove underscore +rownames(roundthetatable) <- sub("\\.", "-", rownames(roundthetatable)) #Change . to - + +parameters1 <- roundthetatable[1:23,c(1,13,2:8)] +parameters2 <- roundthetatable[24:46,c(1,13,2:8)] +probabilities1 <- roundthetatable[1:23,9:12] +probabilities2 <- roundthetatable[24:46,9:12] + + +mysymbolsparam <- c("$\\mu_c$","$\\mu_e$","$\\sigma^2_\\epsilon$","$\\mu_0$","$\\mu_1$","$\\mu_2$","$\\sigma^2_0$","$\\sigma^2_1$","$\\sigma^2_2$") +mysymbolsprobs <- c("$p_{21}$","$p_{23}$","$p_{24}$","$p_{41}$") + +kable(parameters1,booktabs=T, col.names = mysymbolsparam, escape=FALSE) %>% + kable_styling(latex_options = "striped") + +kable(parameters2,booktabs=T,col.names = mysymbolsparam, escape=FALSE) %>% + kable_styling(latex_options = "striped") + + + + +fixroundthetatable <- roundthetatable[,c(1,13,2:12)] +colnames(fixroundthetatable) <- c("mu[c]","mu[e]","sigma[epsilon]^2","mu[0]","mu[1]","mu[2]","sigma[0]^2","sigma[1]^2","sigma[2]^2", + "p[21]","p[23]","p[24]","p[41]") + +longthetatablemus <- fixroundthetatable[c(1,2,4,5,6)] %>% + pivot_longer(cols=`mu[c]`:`mu[2]`) +longthetatablesigmas <- fixroundthetatable[c(3,7,8,9)] %>% + pivot_longer(cols=`sigma[epsilon]^2`:`sigma[2]^2`) + +combinethetatables <- rbind(longthetatablemus,longthetatablesigmas) + +paramdensitycom <- ggplot(combinethetatables, aes(x=value)) + + geom_density(color="black",fill="lightblue") + + facet_wrap(name~.,nrow=5, scales="free", labeller=label_parsed)+ + theme_cowplot() +paramdensitycom + +``` + +\newpage + +\section{Estimates of Probabilities for each Performance} +\label{appendixb} + +```{r,echo=FALSE, message=FALSE, warning=FALSE} +kable(probabilities1,booktabs=T, + col.names = mysymbolsprobs, escape=FALSE) %>% + kable_styling(latex_options = "striped") + +``` + +\newpage + +```{r, echo=FALSE} +kable(probabilities2,booktabs=T, + col.names = mysymbolsprobs, escape=FALSE) %>% + kable_styling(latex_options = "striped") + +longthetatableprobs <- fixroundthetatable[10:13] %>% + pivot_longer(cols=`p[21]`:`p[41]`) + +paramdensityprobs <- ggplot(longthetatableprobs, aes(x=value)) + + geom_density(color="black",fill="lightblue") + + facet_wrap(name~.,nrow=2, scales="free", labeller=label_parsed)+ + theme_cowplot() +paramdensityprobs +``` + +\section{Plots for each Performance} +\label{appendixd} + +```{r,fig.height=4,echo=FALSE,cache=TRUE} +dynamicsdrop <- dynamics[4:49] +dynamicssorted <- dynamicsdrop[,order(colnames(dynamicsdrop))] +lt = diff(c(dynamics$note_onset, 61)) +for(performance in 1:46){ + yt <- matrix(dynamicssorted[,performance], 1) + theta <- as.matrix(thetatable[performance,],1) + pmats = musicModeldynamics(lt, theta[1], theta[2], theta[3:5], theta[6:8], theta[9:12], theta[13], + c(18,0,0), c(10,2,2)) + beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0), dt, ct, Tt, Zt, + HHt, GGt, yt, transMat, 500, samplemethod = 1)) + states = beam$paths[which.max(beam$weights),] + print(plotStates2(theta,states,yt,dynamics$note_onset,model="dynamics", + c(18,0,0), c(10,2,2),title=perftitle[performance])) + +} +``` + + diff --git a/manuscript/dynamicspaper/Dynamics-Model.pdf b/manuscript/dynamicspaper/Dynamics-Model.pdf new file mode 100644 index 0000000..c3bca76 Binary files /dev/null and b/manuscript/dynamicspaper/Dynamics-Model.pdf differ diff --git a/manuscript/dynamicspaper/Dynamics-Model.tex b/manuscript/dynamicspaper/Dynamics-Model.tex new file mode 100644 index 0000000..bad9e68 --- /dev/null +++ b/manuscript/dynamicspaper/Dynamics-Model.tex @@ -0,0 +1,979 @@ +% !TeX program = pdfLaTeX +\documentclass[12pt]{article} +\usepackage{amsmath} +\usepackage{graphicx,psfrag,epsf} +\usepackage{enumerate} +\usepackage{natbib} +\usepackage{textcomp} +\usepackage[hyphens]{url} % not crucial - just used below for the URL +\usepackage{hyperref} +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + +%\pdfminorversion=4 +% NOTE: To produce blinded version, replace "0" with "1" below. +\newcommand{\blind}{0} + +% DON'T change margins - should be 1 inch all around. +\addtolength{\oddsidemargin}{-.5in}% +\addtolength{\evensidemargin}{-.5in}% +\addtolength{\textwidth}{1in}% +\addtolength{\textheight}{1.3in}% +\addtolength{\topmargin}{-.8in}% + +%% load any required packages here + + + + +\usepackage{booktabs} +\usepackage{pgf} +\usepackage{tikz} +\usepackage[ruled,vlined]{algorithm2e} +\usepackage[toc,page]{appendix} +\usepackage{longtable} +\hypersetup{ colorlinks=true, linkcolor=red, citecolor = blue, urlcolor=cyan, } +\newcommand*{\Appendixautorefname}{appendix} +\usepackage{float} +\floatplacement{figure}{t} +\usepackage[skip=0pt]{caption} +\usepackage{booktabs} +\usepackage{longtable} +\usepackage{array} +\usepackage{multirow} +\usepackage{wrapfig} +\usepackage{float} +\usepackage{colortbl} +\usepackage{pdflscape} +\usepackage{tabu} +\usepackage{threeparttable} +\usepackage{threeparttablex} +\usepackage[normalem]{ulem} +\usepackage{makecell} +\usepackage{xcolor} + +\begin{document} + + +\def\spacingset#1{\renewcommand{\baselinestretch}% +{#1}\small\normalsize} \spacingset{1} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\if0\blind +{ + \title{\bf Switching State Space Models for Interpreting Musical Dynamics} + + \author{ + Robert Granger \\ + Department of Statistics, Indiana University\\ + } + \maketitle +} \fi + +\if1\blind +{ + \bigskip + \bigskip + \bigskip + \begin{center} + {\LARGE\bf Switching State Space Models for Interpreting Musical Dynamics} + \end{center} + \medskip +} \fi + +\bigskip +\begin{abstract} +In this paper, we attempt to illuminate a performer's musical intentions +using a Markov-switching state space model. Specifically, the model we +propose is designed for the dynamics of classical music. Unlike many +other models of trend estimation, this model requires the estimation of +a series of parameters. These parameters can be viewed as hidden musical +attributes of a performance that would not be revealed through the +calculation of simple statistics. For this analysis, we use dynamics +data of 46 different performances of Chopin's Mazurka Op. 68 No.~3. from +the Centre for the History and Analysis of Recorded Music (CHARM) +Mazurka Project. +\end{abstract} + +\noindent% +{\it Keywords:} classical music, hidden Markov model +\vfill + +\newpage +\spacingset{1.45} % DON'T change the spacing! + +\def\algorithmautorefname{Algorithm} + +\hypertarget{introduction}{% +\section{Introduction}\label{introduction}} + +In this paper, we attempt to illuminate a performer's musical intentions +surrounding the dynamics of classical music. Through the use of a +Markov-switching state space model, the series of dynamics values within +a single performance are carefully smoothed with the goal of +differentiating the perceived intentions of the performer from the +observed dynamics found in the data. Classical music is different from +other types of music as a composer creates a piece, but many performers +may play it adding their own interpretation. While, the composer gives +some specific direction like the pitch of notes to play, the +instructions regarding dynamics are relatively vague. For example, when +performing a piece, a performer will observe a \emph{p} which stands for +\emph{piano}, indicating this section should be played ``softly''. +Meanwhile, an \emph{f} stands for \emph{forte} and indicates the given +section should be played ``loudly''. While we would expect the +\emph{forte} section to be played louder than the \emph{piano} section, +no direction is given on how softly or loudly the specified section +should be played. The performer may also attempt to ease into a +\emph{piano} section from a \emph{forte} section or they may want to +make a sudden change. These decisions are left to the interpretation of +the performer. + +There are a variety of different trend estimating techniques, but we +propose using a Markov-switching state space model for two reasons. +First, the technique should incorporate actions found within a +performance. Often times, performers make dramatic changes in dynamics +to start a new section, something we want our model to identify, not +smooth out as noise. Likewise, this may extend to individual notes where +intentional emphasis is used by the performer. Using smoothing +techniques like a moving average or spline would ignore these key +elements. The second reason for using this type of model is that it +requires the estimation of certain parameters. These parameters offer +additional insight and can be viewed as hidden attributes of a +performance. Attributes found through simple calculation of averages and +variances would ignore the complexity of the decisions made during a +performance. + +Similar analysis of modelling musical performances with Markov-switching +state space models has been performed on tempo data +\citep{mcdonald_markov-switching_2019,gu_modeling_2012}. When modeling +tempo, the expectation is for the performer to hold a constant tempo, +with some periods of potential speeding up or slowing down. This same +expectation cannot be said for the dynamics and thus requires a +different model setup. Although a Markov-switching state space model can +still be used, the difference comes in the selection of different +discrete states and parameter matrices. While Gu and Raphael did give +some attention to modeling dynamics, this paper looks to expand their +work. + +\def\sectionautorefname{Section} + +The paper procedes as follows: \autoref{Sec:model} begins with a general +description of Markov-switching state space models followed with +specific details regarding the states and the parameter matrices used to +model musical dynamics. \autoref{sec:analysis} explains the algorithm +used to evaluate the model and discusses results for several +performances. \autoref{sec:conclusion} briefly concludes with potential +uses of this model along with potential future areas of research. + +\section{The Markov-Switching State Space Model} +\label{Sec:model} + +State space models are commonly used to model time series observations +in the presence of hidden, continuous states. As a result of the state +space framework, the observations are viewed as independent conditional +on the hidden states whereas these hidden states will follow a vector +autoregressive process. Adding assumptions of linearity and normal error +produces what is commonly referred to as the general linear Gaussian +state space model \citep{durbin_time_2012}. It takes the form +\begin{equation} + \begin{aligned} + y_t &= C_t + D_tx_t + \epsilon_t, + & \epsilon_t & \sim N(0,G_t)\\ + x_{t+1} &= A_t + B_tx_t + \eta_t, + & \eta_t & \sim N(0,H_t), + & x_1 & \sim N(x_0,P_0) \\ + \end{aligned} + \label{eq:statespacemod} +\end{equation} where the first part of \autoref{eq:statespacemod} is +known as the observation equation and the second part is known as the +state equation. The vector \(y_t\) consists of the known observations at +each time period, \(t\), whereas the vector \(x_t\) consists of the +unobserved, continuous states on which \(y_t\) is dependent. The +observation error, \(\epsilon_t\), and the state equation error, +\(\eta_t\), are assumed to be serially independent and independent of +each other. + +In the typical state space framework, the matrices \(A_t\), \(B_t\), +\(C_t\), \(D_t\), \(G_t\), and \(H_t\) are allowed to vary across time +but are known. If there are a finite number of perceived structures for +these matrices, and the given structure is unknown at time, \(t\), a +Markov-switching state space model can be used. This model assumes there +are some underlying discrete states, \(s_t\), that transition over time +through a Markov process. Making this slight adjustment to +\autoref{eq:statespacemod} yields the following model which will be used +as a basic framework for modeling music dynamics. + +\begin{equation} + \begin{aligned} + y_t &= C_t(s_t) + D_t(s_t)x_t + \epsilon_t, + & \epsilon_t & \sim N(0,G_t)\\ + x_{t+1} &= A_t(s_t) + B_t(s_t)x_t + \eta_t, + & \eta_t & \sim N(0,H_t), + & x_1 & \sim N(x_0,P_0) \\ + \end{aligned} + \label{eq:switchstatemodel} +\end{equation} + +When it comes to musical dynamics, rarely do musicians attempt to play +with the same dynamics or loudness throughout the entirety of a piece. +Most of the time we expect the musician to steadily change the loudness +from note to note; however, there may exist moments where the musician +deviates greatly from the trend with either louder or softer than usual +notes. A single note may be played more loudly because the performer is +specifically trying to add emphasis. Adding this emphasis may be on the +performer's own perogative or may be dictated by the piece with an +accent, ``\textbf{$>$}''. On the other hand, a single note appearing in +the data more softly is likely not part of the performer's intent. If a +note in the data is played more softly, it may be because the performer +missed a note or did not hit it as hard as intended. It could also be +something went wrong in the data creation step. Regardless, we do not +attempt to identify why the dynamics data indicates an unusually soft +note, but it is important to include this in our model for statistical +estimation purposes. We tried estimating without explicitly +incorporating these low sounds in the model, but the excessive +statistical noise caused the model to falsely indicate starts of new +smooth progressions. Therefore, in order to model the described +behavior, we propose the following four discrete states: + +\begin{list}{}{} + +\item[$s^1$:] The musician selects a new value for loudness. + +\item[$s^2$:] The musician continues the dynamics in a steady way. + +\item[$s^3$:] The musician plays a single note more loudly. + +\item[$s^4$:] The musician plays a single note more softly. + +\end{list} + +The observation, \(y_t\) is the univariate loudness of the note at each +time period, \(t\). In order to allow the dynamics to progress steadily, +the continuous hidden states, \(x_t\), follow a process that allows for +piece-wise quadratics. At each time period, \(x_t\), is a vector of +length three, \[x_t^\prime = (x^0_t, x^1_t, x^2_t), \] where \(x^0_t\) +is the loudness, \(x^1_t\) is the first order difference, and \(x^2_t\) +is the second order difference. The aim is to maintain this smooth +progression even when the musician plays a single note more loudly or +softly. The states \(s^3\) and \(s^4\) are therefore implemented by +adding a constant in the observation equation as opposed to changing the +state equation. The model is similar to that proposed in +\cite{gu_modeling_2012}, but extended to include these additional +states. \autoref{tab:parmats} shows the parameter matrices for the four +states. + +\begin{table} +\caption{Parameter matrices for the switching state space model.\label{tab:parmats}} +\centering +\begin{tabular}[h!]{@{}ccccccccc@{}} +\toprule +%&&&\multicolumn{3}{c}{Parameter Matrices}\\ + \multicolumn{2}{c}{States} &\phantom{a}& \multicolumn{6}{c}{Parameter Matrices}\\ + \cmidrule{1-2} \cmidrule{4-9} + \multicolumn{2}{c}{$S$}&& $A$ & $B$ & $C$ & $D$ & $G$ & $H$ \\ + \midrule + \multicolumn{2}{c}{$s^1$} && $\begin{pmatrix} \mu_0 \\ \mu_1 \\ \mu_2 \end{pmatrix}$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$ & 0 & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} \sigma_0^2&0&0 \\ 0&\sigma_1^2&0 \\ 0&0&\sigma_2^2 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^2$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & 0 & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^3$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & $\mu_c$ & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + \\ + \multicolumn{2}{c}{$s^4$} && $\begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix}$ & $\begin{pmatrix} 1&1&0 \\ 0&1&1 \\ 0&0&1 \end{pmatrix}$ & $\mu_e$ & $\begin{pmatrix} 1&0&0 \end{pmatrix}$ & $\sigma_\epsilon^2$ & $\begin{pmatrix} 0&0&0 \\ 0&0&0 \\ 0&0&0 \end{pmatrix}$\\ + +\bottomrule +\end{tabular} +\end{table} + +The final part of the switching state space model is designing the +Markov process for transitioning between the discrete states which is +displayed in \autoref{fig:transmat}. The first state, \(s^1\), allows +for the selection of a new loudness which then transitions into the +smooth progresson state, \(s^2\), with probability 1. When arriving in +\(s^2\), the next time period's discrete state can be any of the +possible states including itself. If in this progression, we move to a +sudden loud note, \(s^3\), or a sudden soft note, \(s^4\), then we have +the opportunity to continue the smooth progression, \(s^2\), or start a +new smooth progression, \(s^1\). It is not permissible though to +immediately then play another sudden loud or soft note. + +In total, there are 13 unknown parameters, \(\theta \in \Theta\), spread +across 4 different discrete states, \(s^i \in S\), through \(T\) time +periods. A summary of the parameters to be estimated are: +\(\Theta = \{\mu_c, \mu_e, \sigma^2_\epsilon, \mu_0, \mu_1, \mu_2, \sigma^2_0, \sigma^2_1, \sigma^2_2, p_{21}, p_{23}, p_{24}, p_{41}\}\). +Note this vector contains only four probabilities. With four states, the +transition matrix could potentially have up to twelve probabilities +requiring estimation; however, because of the restrictions placed on the +possible transitions, this number is reduced to four. In the next +section, we discuss finding smoothed estimates of the dynamics which +requires estimation of these parameters along with the continuous and +discrete states. + +\begin{figure}[tb!] +\caption{Transition diagram. \label{fig:transmat}} + \centering + \tikzstyle{switch}=[rectangle, + thick, minimum size=1cm, draw=black] + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] + \matrix[row sep=0.25cm,column sep=.5cm] { + &&& \node (S1) [switch] {$s^1$};&&& \\ + \\ \\ \\ \\ \\ \\ + &&& \node (S2) [switch] {$s^2$};&&& \\ + \\ \\ \\ \\ \\ \\ + &\node (S3) [switch] {$s^3$}; &&&& \node (S4) [switch] {$s^4$};\\ + }; + \path[->] + (S1) edge [bend right] node [left] {1}(S2) + (S2) edge [bend right] node [right] {$p_{21}$}(S1) + (S2) edge [loop above] node [left] {}(S2) + (S2) edge [bend right] node [right] {$p_{23}$}(S3) + (S2) edge [bend right] node [right] {$p_{24}$}(S4) + % (S3) edge [bend left] node [left] {$p_{31}$}(S1) + (S3) edge [bend right] node [left] {1}(S2) + (S4) edge [bend right] node [right] {$p_{41}$}(S1) + (S4) edge [bend right] node [left] {}(S2); + \end{tikzpicture} +\end{figure} + +\section{Evaluating the Model} +\label{sec:analysis} + +Evaluation of the model requires the estimation of the parameters, +\(\theta \in \Theta\); the discrete states, \(\{s_t\}^T_{t=1}\); and the +continuous hidden states \(\{x_t\}^T_{t=1}\). These estimates are +obtained using only the assumptions and structure of the model along +with the observed dynamics, \(\{y_t\}^T_{t=1}\). Once these estimates +are obtained, we then compute predicted values, \(E[y_t|...]\), which +can be thought of as the performer's intended dynamics. Hence, the aim +in estimating the intended dynamics is attempting to remove +\(\epsilon_t\), which can be seen as unintended deviations from the +desired loudness. + +\subsection{The Algorithm} + +When the parameter values, \(\theta_i \in \Theta\), and the discrete +states, \(\{s_t\}^T_{t=1}\), are known, the Kalman filter +\citep{kalman_new_1960} can be used to find estimates of the continuous +hidden states, \(\{x_t\}_{t=1}^T\), along with the likelihood. While the +Kalman filter provides an easy way to compute the likelihood, the +estimate of \(x_t\) is obtained using only observations coming before +time \(t\). In order to use all information, we implement the Kalman +smoothing algorithm introduced in \citep{rauch_maximum_1965}. This +algorithm provides an estimate, \(\hat{x_t} = E[x_t|y_1,...y_T]\), which +can be used to compute a fitted or ``smoothed'' value, \(\hat{y_t}\). + +The Kalman smoother provides a closed form solution to obtaining the +maximum likelihood estimates of our continuous hidden states, but what +if the discrete states, \(\{s_t\}^T_{t=1}\), are unknown? We can obtain +the most likely set of discrete states by simply running the Kalman +smoother algorithm on every possible combination of discrete states and +choosing the set of discrete states that yields the largest likelihood. +This may work if the number of discrete states and/or time periods is +small; however, the number of state combinations to check may be large +and can be computed as \(|\{s^i \in S\}|^T\). For example, the music +dynamics model presented in the previous section has four discrete +states and the piece to be evaluated, Chopin's Mazurka Op.~68 No.~3, has +231 notes. This brings the grand total of state combinations to check to +\(4^{231}\approx1.19\times 10^{139}\). Of course, many of these state +combinations could be removed due to 0 likelihood given the restrictions +on the state transitions, but even with this taken into account, the +number of state combinations is far too large. To overcome this issue, +we use the Discrete Particle Filter as described in +\cite{mcdonald_markov-switching_2019}. We begin by estimating the +partial likelihood iteratively through time at each of the possible +discrete state paths using the Kalman Filter. Each of these paths is +known as a particle with only the previous states and partial likelihood +being saved. This process would still require checking all +\(|\{s^i \in S\}|^T\) paths, so to get around this, we implement the +greedy search algorithm called Beam Search. This search algorithm +requires selecting a maximum number of particles to save at each time +iteration and discards the rest. + +\begin{figure}[tb!] + \centering + \tikzstyle{switch}=[rectangle, + thick, minimum size=0.5cm, draw=black] + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] + \matrix[row sep=0.25cm,column sep=.75cm] { + \node (S1) [switch] {$s_1$}; &&\node (S4) [switch] {$s_1s_1$};&& \node (S7) [switch] {$s_1s_1$}; && \node (S8) [switch] {$s_1s_1s_1$}; && \node (S9) [switch] {$s_1s_1s_1$}; &&\\ + \\ + && && && \node (S13) [switch] {$s_1s_1s_2$};\\ + \\ + &&\node (S3) [switch] {$s_1s_2$}; && \node (S10) [switch] {$s_1s_2$}; && \node (S14) [switch] {$s_1s_2s_1$}; && \node (S20) [switch] {$s_1s_2s_1$}; \\ + \\ + && && && \node (S15) [switch] {$s_1s_2s_2$}; && \node (S21) [switch] {$s_2s_2s_2$}; \\ + \\ + \node (S2) [switch] {$s_2$}; &&\node (S5) [switch] {$s_2s_1$};&&\node (S11) [switch] {$s_2s_1$};&& \node (S16) [switch] {$s_2s_1s_1$}; && \node (S22) [switch] {$s_2s_1s_1$}; \\ + \\ + && && && \node (S17) [switch] {$s_2s_1s_2$};&&\node (S23) [switch] {$s_2s_1s_2$}; + \\ + &&\node (S6) [switch] {$s_2s_2$};&&\node (S12) [switch] {$s_2s_2$};&& \node (S18) [switch] {$s_2s_2s_1$};\\ + \\ + &&&&&& \node (S19) [switch] {$s_2s_2s_2$}; &&\\ + \\ + \hline + \\ + \\ + $t=1$ && && \hspace{12px} $t=2$ && && \hspace{52px} $t=3$ \\ + }; + \path[->] + (S1) edge (S3) + (S7) edge (S8) + (S7) edge (S13) + (S8) edge [dashed] (S9) + (S10) edge (S14) + (S10) edge (S15) + (S11) edge (S16) + (S11) edge (S17) + (S4) edge [dashed] (S7) + (S1) edge (S4) + (S2) edge (S5) + (S12) edge (S18) + (S12) edge (S19) + (S3) edge [dashed] (S10) + (S5) edge [dashed] (S11) + (S6) edge [dashed] (S12) + (S14) edge [dashed] (S20) + (S15) edge [dashed] (S21) + (S16) edge [dashed] (S22) + (S17) edge [dashed] (S23) + (S2) edge (S6); + \end{tikzpicture} + \caption{Discrete Particle Filter with 2 discrete states and capping the maximum number of stored particles at 5 for each time iteration. \label{fig:dpf}} +\end{figure} + +\autoref{fig:dpf} illustrates this concept with 2 discrete states and +the maximum number of particles set at 5. There are four possible state +paths to check when passing from \(t=1\) to \(t=2\) which is less than +the maximum particle number so all four paths are saved. When moving +from \(t=2\) to \(t=3\), the number of paths increases to 8. Since only +5 paths are allowed, three of these paths must be dropped and will no +longer be considered as possible solutions. In order to decide which +paths are to be saved a sampling procedure must be performed. One +sampling procedure proposed by \citep{tugnait_detection_1982} is to +simply keep the paths that have the highest likelihood. Another sampling +procedure proposed by \citep{akashi_random_1977} is to randomly sample +one particle out of the total number of states descended from each of +the \(t-1\) particles in proportion to their respective likelihoods. +\citep{fearnhead_-line_2003} proposes another stochastic approach but +one that minimizes the expected mean squared error between the +approximated distribution and the true distribution's probabilities. +This approach determines a threshold value such that all particles with +likelihood above this value are kept and the remaining particles to be +kept are chosen at random with probability equal to their respective +likelihoods. Once a sampling technique is selected and the procedure is +implemented through all time points, a sample of discrete state +sequences is saved the size of the beam width. Since the goal of this +paper is to find the most likely sequence of discrete states, the one +with the highest likelihood is selected. + +\begin{algorithm}[t] + \caption{Solving Music Dynamics Model\label{alg:masteralgorithm}} +\SetAlgoLined + \textbf{Input} Y, a vector of observed dynamics\; + \textbf{Initialize} $\Theta$\; + \While{(Stopping Criteria)}{ + Create Matrices A, B, C, D, G, H at each $t$ for each $s^i \in S$\; + Implement Discrete Particle Filter\; + Compute the log-likelihood: \hspace{2px} $l(Y|\Theta,S) + l(S|\Theta) + l(\Theta)$\; + Update $\Theta$ via Nelder-Mead Optimization or SANN\; + } +\end{algorithm} + +The final step is estimating the model parameters, \(\Theta\), that +maximize the likelihood. This is a difficult task as this model presents +a couple of problems: 1) many of the parameters are constrained as +variances need to be positive and the probabilities of leaving the same +state should sum to 1 while also being constrained between 0 and 1; 2) +there are many local maxima making finding a global maxima difficult. To +help alleviate these concerns, we can include Bayesian priors on our +parameters. Using carefully selected priors allows us to steer the +algorithm away from impossible solutions and direct it toward more +desired solutions. These issues also lead us to carefully consider our +optimization technique. We will use two different methods. The first is +the Nelder-Mead algorithm which can find local maxima for unconstrained +multidimensional problems without the need for derivative computation +\citep{nelder_simplex_1965}. The second is the Simulated Annealing +(SANN) algorithm which is commonly used when dealing with problems with +many local maxima in order to estimate the global maxima. Neither of +these methods are perfect at avoiding a local maximum and hence the +selection of initial values plays an important role. To overcome this +challenge, we will select a variety of different starting points drawn +randomly from the Bayesian priors. + +\vspace{10px} + +\autoref{alg:masteralgorithm} displays the complete procedure. The +solution to this model was found using software R +\citep{r_core_team_r_2019}. The Nelder-Mead and SANN methods are +performed using the package \texttt{optimr} by \cite{nash_optimr_2019}. +The discrete particle filter was implemented by extending the package +\texttt{dpf} by \cite{mcdonald_dpf_2020}. + +\subsection{Results for Chopin's Mazurka Op.\ 68 No.\ 3} + +\begin{table}[t] + \caption{Informative prior distributions for Chopin's Mazurka Op.\ 68 No.\ 3} + \centering + \begin{tabular}{@{}rcll@{}} + \toprule + Parameter & \phantom{a} & Distribution & Prior Mean \\ + \midrule + $\mu_c$ & $\sim$ & Gamma$(100,\ 0.1)$ & 10\\ + $\mu_e$ & $\sim$ & -Gamma$(100,\ 0.1)$ & -10\\ + $\sigma^2_{\epsilon}$ & $\sim$ & Gamma$(10,\ 0.5)$ & 5\\ + $\mu_{0}$ & $\sim$ & Normal$(\overline{Y},\ 10)$ & $\overline{Y}$\\ + $\mu_{1} $ & $\sim$ & Normal$(0,\ 0.25)$ & 0\\ + $\mu_{2} $ & $\sim$ & Normal$(0,\ 0.25)$ & 0\\ + $\sigma^2_{0} $ & $\sim$ & Gamma$(10,\ 1)$ & 10 \\ + $\sigma^2_{1} $ & $\sim$ & Gamma$(3,\ 1)$ & 3 \\ + $\sigma^2_{2} $ & $\sim$ & Gamma$(3,\ 1)$ & 3 \\ + $p_{2,\cdot}$ & $\sim$ & Dirichlet$(5,\ 85,\ 5,\ 5)$ & 0.05, 0.85, 0.05, 0.05 \\ + % $p_{3,\cdot}$ & $\sim$ & Beta$(2,\ 8)$ & 0.20\\ + $p_{4,\cdot}$ & $\sim$ & Beta$(2,\ 8)$ & 0.20\\ + \bottomrule + \end{tabular} + \label{tab:priors} +\end{table} + +The model was estimated using observed dynamics from forty-six different +performances of Chopin's Mazurka Op.~68 No.~3. This data was reverse +conducted (created) by Craig Sapp using Andrew Earis's Expression +Algorithm software. The software and data can be found on the website +for the Centre for the History and Analysis of Recorded Music (CHARM) +Mazurka Project \citep{charm_centre_2009}. The technique used to create +the data is described in detail in Andrew Earis's paper ``An algorithm +to extra expressive timing and dynamics from piano recordings'' +\citep{earis_algorithm_2007}. + +To implement \autoref{alg:masteralgorithm} on dynamics data from +performances of Chopin's Mazurka Op.~68 No.~3, we must make a few +specific decisons. First, we choose prior distributions applicable +specifically to Chopin's Mazurka Op.~68 No.~3, which can be found in +\autoref{tab:priors}. Secondly, regarding the Discrete Particle Filter, +we selected to keep up to 500 particles with the sampling criterion of +keeping the largest likelihoods. Lastily, since there are many local +minima, we used 10 different starting points drawn randomly and +independently from each of the prior distributions for each optimization +technique (both Nelder-Mead and SANN). + +\begin{figure} +\centering +\includegraphics{Dynamics-Model_files/figure-latex/exampletable-1.pdf} +\caption{\label{fig:exampletable}Interpreted Dynamics from selected +performances of Chopin's Mazurka Op. 68 No.~3. The black line traces the +observed dynamics while the colored dots are the smoothed interpreted +dynamics.} +\end{figure} + +Graphical representations for the performances of Jean-Marc Luisada in +1991 and Arthur Rubinstein in 1966 are shown in +\autoref{fig:exampletable}. These along with plots of the other +forty-four performances can be found in \autoref{appendixd}. The black +line traces the observed dynamics for each note across musical time as +given by the score. The colored dots are used to differentiate the 4 +possible discrete states and show the interpreted musical dynamics for +each note. The background is shaded based on musical directions given by +the composer in the score. Notice with these performances, the model +often seems to start a new smooth progression when the composer gives +direction about the dynamics. There are occasions where this is not +always the case. Notice that Luisada appears to smoothly adjust the +dynamics from the second \emph{piano} section into the +\emph{poco piu vivo} section and again when transitioning from the final +\emph{forte} section to the final \emph{piano} section. Similarly, +Rubinstein also smoothly transitions but he does this between the first +\emph{forte} section into the only \emph{fortissimo} section. These +unscripted parts of the performance are what we hope to discover as they +allow us to contrast and compare each performance. + +\begin{table} + +\caption{\label{tab:table3}Parameter Estimates for Selected Performances of Chopin's Mazurka Op.68 No.3\label{tab:parameterestimatesrichter}} +\centering +\begin{tabular}[t]{lrrrrrrrrr} +\toprule + & $\mu_c$ & $\mu_e$ & $\sigma^2_\epsilon$ & $\mu_0$ & $\mu_1$ & $\mu_2$ & $\sigma^2_0$ & $\sigma^2_1$ & $\sigma^2_2$\\ +\midrule +\rowcolor{gray!6} Block 1995 & 8.812 & -9.777 & 4.946 & 17.036 & 0.121 & -0.075 & 15.546 & 0.215 & 0.006\\ +Grinberg 1951 & 10.038 & -9.342 & 5.906 & 19.381 & 0.553 & -0.094 & 16.676 & 0.396 & 0.006\\ +\rowcolor{gray!6} Hatto 1993 & 9.871 & -10.167 & 6.524 & 10.913 & 0.050 & -0.042 & 9.900 & 0.359 & 0.002\\ +Luisada 1991 & 10.455 & -9.949 & 13.068 & 27.312 & -0.165 & -0.110 & 12.098 & 1.612 & 0.067\\ +\rowcolor{gray!6} Richter 1976 & 9.541 & -10.499 & 4.399 & 23.422 & -0.346 & -0.001 & 16.294 & 0.260 & 0.003\\ +\addlinespace +Rubinstein 1966 & 10.771 & -10.065 & 8.091 & 12.840 & 0.470 & -0.033 & 17.045 & 0.401 & 0.000\\ +\rowcolor{gray!6} Sofronitsky 1949 & 9.944 & -10.538 & 9.154 & 27.735 & -0.234 & -0.070 & 13.768 & 0.659 & 0.019\\ +\bottomrule +\end{tabular} +\end{table} + +\begin{table} + +\caption{\label{tab:table3ext}Probability Estimates for Selected Performances of Chopin's Mazurka Op.68 No.3\label{tab:probestimatesrichter}} +\centering +\begin{tabular}[t]{lrrrr} +\toprule + & $p_{21}$ & $p_{23}$ & $p_{24}$ & $p_{41}$\\ +\midrule +\rowcolor{gray!6} Block 1995 & 0.101 & 0.027 & 0.025 & 0.124\\ +Grinberg 1951 & 0.067 & 0.027 & 0.027 & 0.077\\ +\rowcolor{gray!6} Hatto 1993 & 0.056 & 0.070 & 0.067 & 0.053\\ +Luisada 1991 & 0.037 & 0.020 & 0.024 & 0.136\\ +\rowcolor{gray!6} Richter 1976 & 0.046 & 0.017 & 0.051 & 0.044\\ +\addlinespace +Rubinstein 1966 & 0.034 & 0.017 & 0.023 & 0.214\\ +\rowcolor{gray!6} Sofronitsky 1949 & 0.060 & 0.015 & 0.019 & 0.101\\ +\bottomrule +\end{tabular} +\end{table} + +Analyzing the graphical representations of each performance have the +benefit of illuminating complexities within a performance but may be +cumbersome when attempting to compare and contrast many performances. +Instead, we analyze the parameter and transition probability values, +\(\Theta\). All estimated values for the 46 performances can be found in +\autoref{appendixa} and \autoref{appendixb}. For the reader's +convenience, the parameter estimates for performances discussed in this +section can be found in \autoref{tab:parameterestimatesrichter} and +\autoref{tab:probestimatesrichter}. Along with the tables of estimated +parameters, we also supply density plots of the estimated parameters. +These density plots show the distribution of the estimated parameters +and should not be mistaken for the estimated posterior distributions for +some performance. + +\begin{figure} +\centering +\includegraphics{Dynamics-Model_files/figure-latex/denseplots-1.pdf} +\caption{\label{fig:densityplots}Density Plots of Estimated Parameters +for 46 Performances of Chopin's Mazurka Op. 68 No.~3.} +\end{figure} + +We analyze the density plots in order to get a better understanding of +the distribution of the parameters. We begin with a look at the +estimated parameters, \(\mu_{0}\) and \(\mu_1\). The parameter \(\mu_0\) +can be interpreted as the most likely starting point for each smoothed +quadratic section. Joyce Hatto's 1993 performance is estimated to have +the lowest average starting point with \(\mu_0=\) 10.913 and Vladimir +Sofronitsky's 1949 performance is estimated to have the highest average +starting point with \(\mu_0=\) 27.74. The average of all the \(\mu_0\)'s +across all 46 performances is \texttt{19.148}. +\autoref{fig:densityplots} displays the density plot of \(\mu_0\) which +reveals the distribution of \(\mu_0\)'s is fairly symmetric but with +more concentration around the mean than the normal distribution. The +parameter \(\mu_1\) can be interpreted as the average initial change in +the dynamics of a performance. As long as \(\mu_2\) is small relative to +\(\mu_1\) or if they both have the same sign, this change will +persistent through each smoothed quadratic section. The parameter +estimates for these performances range from a low of -0.346 in +Sviatoslav Richter's 1976 performance to a high of 0.553 in Maria +Grinberg's 1951 performance. From the density plot for \(\mu_1\), the +distribution of the estimated parameters appears roughly normal with a +mean equal to \texttt{0.103}. The mean being greater than zero indicates +that, on average, performers tend to (at least initially) increase the +volume through each smoothed quadratic section. + +In order to get a fuller understanding of the parameters, we compare the +estimated parameters in Luisada's 1991 performance with Rubinstein's +1966 performance. Luisada's 1991 performance has \(\mu_0 = 27.312\), +\(\mu_1=-0.165\), and \(\mu_2=-0.110\) indicating that he typically +starts loudly and then softens. On the other hand, Rubinstein's +performance has \(\mu_0 = 12.840\), \(\mu_1=0.470\) and +\(\mu_2=-0.033\), indicating that he typically starts each smoothed +section more softly and then gets louder. Taking an average across all +note dynamics for the Luisada 1991 and Rubinstein 1966 performances +yields \texttt{17.33} and \texttt{20.98}, respectively. While it is +interesting to know that Rubinstein's 1966 was louder, on average, than +Luisada's 1991 performance, we can see that without modeling the +performer's intentions, interesting details are being missed. We also +analyze the variance within each performance. Calculating the overall +variation of note dynamics for the Luisada 1996 performance reveals a +variance of \texttt{48.39}. Calculating the overall note dynamics of the +Rubinstein 1996 performance reveals more homogeneity with a variance of +\texttt{31.84}. Although the variation in note dynamics is higher for +the Luisada 1996 performance, we observe through modelling the +performer's intentions that Luisada typically has less variation in the +starting dynamics of each piece-wise quadratic section than Rubinstein +with \(\sigma^2_0=12.098\) and 17.045, respectively. This is a new +characteristic of the performance that would be otherwise hidden without +using the music dynamics model. + +Lastly, we compare the four estimated transition probabilities. The +estimates for \(p_{21}\) and +\(p_{41}\)\footnote{We focus on $p_{21}$ more than $p_{41}$ as being in state 4 is much less likely. } +show how likely is it for the performer to start a new smoothed section. +The model also reveals how likely the performer will emphasize a note by +playing it more loudly through the estimated value \(p_{23}\). For the +Luisada 1991 and Rubinstein 1966 performances, all of the probabilities +are relatively the same, but we do find differences in some of the other +performances. For example, while the Luisada 1991 and Rubinstein 1966 +performances have relatively low probabilities in starting a new +smoothed section, Michel Block's 1995 performance is more likely with +\(p_{21}=.101\). Also, the Block 1995 performance is more likely to have +emphasized notes with estimated \(p_{23}=0.027\), a probability larger +than either Luisada and Rubinstein's performances. + +\section{Conclusion} +\label{sec:conclusion} + +Using a Markov-switching state space model, we were able to illuminate +the intentions of a classical music performance with regards to the +dynamics. In the process, a series of parameters were estimated that can +be perceived as musical attributes hidden in the data. Using these +attributes, we discussed a few pieces and showed various characteristics +that would have been hidden by simply sticking to commonly used +statistics like means or standard deviations. We then proceeded to make +contrasts and comparisons of the various pieces based on these musical +attributes. + +The analysis described here can be taken a step further. In +\cite{mcdonald_markov-switching_2019}, the authors chose to cluster the +performances based on the estimated parameters from their tempo model +using hierarchical clustering. With the estimated parameters here and/or +combining them with the estimated parameters of their tempo model, one +could use their favorite clustering or classifying techniques on the +performances. With additional knowledge from the data, it seems likely +that the ability to cluster or classify would be improved. + +Clustering and classifying are the foundational methods used in music +recommendation systems that many users of music media platforms rely in +order to discover or find new music. For example, the fast growing +online music streaming service, Spotify, has a ``Made For You'' section +that creates recommended playlists for the user based on their listening +habits. In order to provide these recommendations, Spotify's algorithm +takes into consideration information about which songs you ``like'', +``share'', and even ``skip'' along with information from other users +that are deemed similar \citep{spotify_spotify_2019}. While it is +certainly advantageous to use data from users experience, more +information can be obtained by focusing on the musical attributes of a +performance itself. Pandora, another music streaming service, created +the Music Genome Project where a team of musicologists listen and +analyze music in order to assign 450 musical attributes +\citep{pandora_music_2020}. These 450 ``genes'' allow the streaming +company to classify or cluster musical pieces in order to make +recommendations to its users. It would be interesting to see if and how +these additional parameters can improve the ability to classify +performances and ultimately create better musical recommendation +systems. + +\newpage + +\appendix +\appendixpage +\addappheadtotoc + +\section{Estimates of Parameters for each Performance} +\label{appendixa} + +\begin{table}[H] +\centering +\begin{tabular}{lrrrrrrrrr} +\toprule + & $\mu_c$ & $\mu_e$ & $\sigma^2_\epsilon$ & $\mu_0$ & $\mu_1$ & $\mu_2$ & $\sigma^2_0$ & $\sigma^2_1$ & $\sigma^2_2$\\ +\midrule +\rowcolor{gray!6} Bacha 1997 & 10.07 & -9.89 & 9.08 & 18.80 & -0.01 & -0.02 & 11.81 & 0.16 & 0.00\\ +Barbosa 1983 & 9.72 & -10.03 & 8.07 & 21.56 & -0.07 & -0.01 & 7.62 & 0.56 & 0.06\\ +\rowcolor{gray!6} Biret 1990 & 9.80 & -10.10 & 7.14 & 14.57 & 0.08 & -0.02 & 11.50 & 0.19 & 0.00\\ +Block 1995 & 8.81 & -9.78 & 4.95 & 17.04 & 0.12 & -0.07 & 15.55 & 0.21 & 0.01\\ +\rowcolor{gray!6} Brailowsky 1960 & 10.33 & -11.21 & 9.98 & 25.96 & 0.22 & -0.03 & 11.85 & 0.10 & 0.00\\ +\addlinespace +Chiu 1999 & 10.29 & -9.90 & 6.44 & 13.10 & 0.13 & 0.00 & 13.43 & 0.45 & 0.01\\ +\rowcolor{gray!6} Clidat 1994 & 10.09 & -9.46 & 6.68 & 21.43 & 0.05 & 0.01 & 12.21 & 0.65 & 0.01\\ +Cohen 1997 & 10.71 & -8.85 & 7.19 & 22.24 & 0.08 & -0.05 & 17.08 & 0.28 & 0.01\\ +\rowcolor{gray!6} Cortot 1951 & 10.04 & -10.78 & 10.23 & 17.87 & -0.16 & 0.01 & 11.73 & 0.22 & 0.02\\ +Csalog 1996 & 10.24 & -10.06 & 10.54 & 23.20 & -0.07 & -0.04 & 7.20 & 0.55 & 0.53\\ +\addlinespace +\rowcolor{gray!6} Czerny-Stefanska 1990 & 10.85 & -8.98 & 5.52 & 16.52 & 0.27 & -0.05 & 13.42 & 1.19 & 0.00\\ +Ezaki 2006 & 10.00 & -9.04 & 5.95 & 21.22 & -0.15 & 0.01 & 11.26 & 0.13 & 0.00\\ +\rowcolor{gray!6} Ferenczy 1958 & 10.26 & -9.69 & 8.24 & 20.67 & 0.22 & -0.02 & 20.81 & 0.12 & 0.00\\ +Fliere 1977 & 11.48 & -10.58 & 12.40 & 17.68 & 0.28 & -0.05 & 16.40 & 0.50 & 0.01\\ +\rowcolor{gray!6} Fou 1978 & 9.84 & -10.10 & 7.70 & 16.98 & -0.18 & 0.07 & 9.92 & 2.14 & 0.08\\ +\addlinespace +Francois 1956 & 9.78 & -9.89 & 10.95 & 19.55 & -0.05 & 0.02 & 14.47 & 0.33 & 0.01\\ +\rowcolor{gray!6} Grinberg 1951 & 10.04 & -9.34 & 5.91 & 19.38 & 0.55 & -0.09 & 16.68 & 0.40 & 0.01\\ +Hatto 1993 & 9.87 & -10.17 & 6.52 & 10.91 & 0.05 & -0.04 & 9.90 & 0.36 & 0.00\\ +\rowcolor{gray!6} Hatto 2006 & 9.73 & -10.80 & 5.49 & 11.43 & 0.16 & -0.09 & 11.91 & 0.74 & 0.01\\ +Indjic 1988 & 9.47 & -10.16 & 7.99 & 16.69 & 0.00 & -0.03 & 14.92 & 0.53 & 0.00\\ +\addlinespace +\rowcolor{gray!6} Jonas 1947 & 9.89 & -10.39 & 8.45 & 13.21 & 0.20 & -0.04 & 12.59 & 1.69 & 0.03\\ +Kapell 1951 & 10.62 & -10.49 & 6.85 & 17.87 & 0.52 & -0.05 & 12.41 & 0.06 & 0.00\\ +\rowcolor{gray!6} Kiepura 1999 & 10.51 & -9.75 & 9.23 & 14.02 & 0.15 & -0.04 & 8.41 & 0.96 & 0.00\\ +\bottomrule +\end{tabular} +\end{table} + +\begin{table}[H] +\centering +\begin{tabular}{lrrrrrrrrr} +\toprule + & $\mu_c$ & $\mu_e$ & $\sigma^2_\epsilon$ & $\mu_0$ & $\mu_1$ & $\mu_2$ & $\sigma^2_0$ & $\sigma^2_1$ & $\sigma^2_2$\\ +\midrule +\rowcolor{gray!6} Kushner 1989 & 9.92 & -9.22 & 7.28 & 13.00 & 0.41 & -0.03 & 12.24 & 0.10 & 0.00\\ +Luisada 1991 & 10.45 & -9.95 & 13.07 & 27.31 & -0.17 & -0.11 & 12.10 & 1.61 & 0.07\\ +\rowcolor{gray!6} Lushtak 2004 & 9.21 & -8.70 & 6.23 & 14.01 & 0.13 & 0.10 & 14.54 & 0.17 & 0.02\\ +Meguri 1997 & 10.32 & -11.08 & 8.20 & 19.91 & 0.10 & -0.03 & 13.37 & 1.31 & 0.00\\ +\rowcolor{gray!6} Milkina 1970 & 9.63 & -9.71 & 8.09 & 14.11 & 0.29 & -0.02 & 11.50 & 0.50 & 0.00\\ +\addlinespace +Mohovich 1999 & 11.32 & -9.66 & 7.47 & 22.00 & -0.13 & 0.01 & 13.88 & 0.55 & 0.00\\ +\rowcolor{gray!6} Ohlsson 1999 & 9.54 & -9.70 & 7.43 & 22.44 & -0.30 & -0.01 & 11.20 & 0.96 & 0.01\\ +Olejniczac 1990 & 11.03 & -9.00 & 5.74 & 17.27 & 0.14 & 0.02 & 14.22 & 0.32 & 0.00\\ +\rowcolor{gray!6} Rangell 2001 & 9.92 & -11.68 & 7.60 & 15.61 & 0.29 & -0.08 & 9.49 & 0.49 & 0.02\\ +Richter 1976 & 9.54 & -10.50 & 4.40 & 23.42 & -0.35 & 0.00 & 16.29 & 0.26 & 0.00\\ +\addlinespace +\rowcolor{gray!6} Rubinstein 1939 & 9.71 & -8.83 & 6.42 & 22.56 & -0.02 & -0.10 & 10.31 & 1.46 & 0.01\\ +Rubinstein 1952 & 9.79 & -10.36 & 9.50 & 21.26 & -0.02 & -0.01 & 9.83 & 1.32 & 0.01\\ +\rowcolor{gray!6} Rubinstein 1961 & 9.74 & -9.89 & 6.95 & 13.66 & 0.50 & -0.04 & 13.10 & 0.31 & 0.00\\ +Rubinstein 1966 & 10.77 & -10.06 & 8.09 & 12.84 & 0.47 & -0.03 & 17.05 & 0.40 & 0.00\\ +\rowcolor{gray!6} Shebanova 2002 & 10.20 & -10.40 & 10.24 & 18.33 & 0.03 & 0.00 & 5.54 & 0.08 & 0.00\\ +\addlinespace +Smidowicz 1948a & 9.97 & -9.99 & 7.86 & 18.18 & 0.32 & -0.06 & 7.97 & 0.27 & 0.00\\ +\rowcolor{gray!6} Smidowicz 1948b & 10.07 & -9.47 & 7.61 & 27.62 & 0.22 & -0.03 & 13.90 & 0.06 & 0.00\\ +Smith 1975 & 10.51 & -9.57 & 9.21 & 27.66 & 0.02 & -0.10 & 10.95 & 1.12 & 0.02\\ +\rowcolor{gray!6} Sofronitsky 1949 & 9.94 & -10.54 & 9.15 & 27.74 & -0.23 & -0.07 & 13.77 & 0.66 & 0.02\\ +Sztompka 1959 & 9.73 & -9.10 & 6.55 & 23.33 & 0.01 & -0.01 & 10.74 & 0.63 & 0.01\\ +\addlinespace +\rowcolor{gray!6} Tomsic 1995 & 9.44 & -9.22 & 4.62 & 18.17 & 0.41 & -0.11 & 14.28 & 1.19 & 0.03\\ +Uninsky 1971 & 9.93 & -10.87 & 7.42 & 23.89 & 0.12 & -0.06 & 10.56 & 1.28 & 0.01\\ +\rowcolor{gray!6} Wasowski 1980 & 10.31 & -9.73 & 7.26 & 24.58 & 0.07 & -0.01 & 9.85 & 0.12 & 0.00\\ +\bottomrule +\end{tabular} +\end{table} + +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-1-1.pdf} + +\newpage + +\section{Estimates of Probabilities for each Performance} +\label{appendixb} + +\begin{table}[H] +\centering +\begin{tabular}{lrrrr} +\toprule + & $p_{21}$ & $p_{23}$ & $p_{24}$ & $p_{41}$\\ +\midrule +\rowcolor{gray!6} Bacha 1997 & 0.03 & 0.02 & 0.03 & 0.08\\ +Barbosa 1983 & 0.02 & 0.02 & 0.02 & 0.12\\ +\rowcolor{gray!6} Biret 1990 & 0.03 & 0.04 & 0.03 & 0.12\\ +Block 1995 & 0.10 & 0.03 & 0.03 & 0.12\\ +\rowcolor{gray!6} Brailowsky 1960 & 0.05 & 0.03 & 0.09 & 0.04\\ +\addlinespace +Chiu 1999 & 0.04 & 0.02 & 0.03 & 0.07\\ +\rowcolor{gray!6} Clidat 1994 & 0.05 & 0.02 & 0.04 & 0.06\\ +Cohen 1997 & 0.05 & 0.02 & 0.05 & 0.08\\ +\rowcolor{gray!6} Cortot 1951 & 0.03 & 0.01 & 0.06 & 0.29\\ +Csalog 1996 & 0.02 & 0.02 & 0.01 & 0.14\\ +\addlinespace +\rowcolor{gray!6} Czerny-Stefanska 1990 & 0.09 & 0.02 & 0.02 & 0.15\\ +Ezaki 2006 & 0.02 & 0.02 & 0.06 & 0.08\\ +\rowcolor{gray!6} Ferenczy 1958 & 0.03 & 0.04 & 0.05 & 0.08\\ +Fliere 1977 & 0.03 & 0.01 & 0.02 & 0.21\\ +\rowcolor{gray!6} Fou 1978 & 0.05 & 0.02 & 0.03 & 0.09\\ +\addlinespace +Francois 1956 & 0.03 & 0.03 & 0.02 & 0.08\\ +\rowcolor{gray!6} Grinberg 1951 & 0.07 & 0.03 & 0.03 & 0.08\\ +Hatto 1993 & 0.06 & 0.07 & 0.07 & 0.05\\ +\rowcolor{gray!6} Hatto 2006 & 0.05 & 0.04 & 0.07 & 0.05\\ +Indjic 1988 & 0.03 & 0.07 & 0.06 & 0.04\\ +\addlinespace +\rowcolor{gray!6} Jonas 1947 & 0.06 & 0.04 & 0.02 & 0.10\\ +Kapell 1951 & 0.06 & 0.02 & 0.03 & 0.05\\ +\rowcolor{gray!6} Kiepura 1999 & 0.03 & 0.02 & 0.02 & 0.14\\ +\bottomrule +\end{tabular} +\end{table} + +\newpage + +\begin{table}[H] +\centering +\begin{tabular}{lrrrr} +\toprule + & $p_{21}$ & $p_{23}$ & $p_{24}$ & $p_{41}$\\ +\midrule +\rowcolor{gray!6} Kushner 1989 & 0.04 & 0.01 & 0.04 & 0.19\\ +Luisada 1991 & 0.04 & 0.02 & 0.02 & 0.14\\ +\rowcolor{gray!6} Lushtak 2004 & 0.08 & 0.06 & 0.04 & 0.05\\ +Meguri 1997 & 0.03 & 0.01 & 0.02 & 0.06\\ +\rowcolor{gray!6} Milkina 1970 & 0.05 & 0.03 & 0.02 & 0.28\\ +\addlinespace +Mohovich 1999 & 0.05 & 0.02 & 0.02 & 0.11\\ +\rowcolor{gray!6} Ohlsson 1999 & 0.06 & 0.03 & 0.02 & 0.09\\ +Olejniczac 1990 & 0.05 & 0.02 & 0.07 & 0.07\\ +\rowcolor{gray!6} Rangell 2001 & 0.04 & 0.01 & 0.06 & 0.05\\ +Richter 1976 & 0.05 & 0.02 & 0.05 & 0.04\\ +\addlinespace +\rowcolor{gray!6} Rubinstein 1939 & 0.09 & 0.02 & 0.12 & 0.04\\ +Rubinstein 1952 & 0.05 & 0.02 & 0.02 & 0.13\\ +\rowcolor{gray!6} Rubinstein 1961 & 0.04 & 0.02 & 0.03 & 0.05\\ +Rubinstein 1966 & 0.03 & 0.02 & 0.02 & 0.21\\ +\rowcolor{gray!6} Shebanova 2002 & 0.05 & 0.03 & 0.07 & 0.03\\ +\addlinespace +Smidowicz 1948a & 0.04 & 0.02 & 0.05 & 0.05\\ +\rowcolor{gray!6} Smidowicz 1948b & 0.05 & 0.02 & 0.07 & 0.03\\ +Smith 1975 & 0.06 & 0.02 & 0.06 & 0.12\\ +\rowcolor{gray!6} Sofronitsky 1949 & 0.06 & 0.01 & 0.02 & 0.10\\ +Sztompka 1959 & 0.05 & 0.02 & 0.07 & 0.03\\ +\addlinespace +\rowcolor{gray!6} Tomsic 1995 & 0.09 & 0.02 & 0.02 & 0.11\\ +Uninsky 1971 & 0.05 & 0.02 & 0.07 & 0.03\\ +\rowcolor{gray!6} Wasowski 1980 & 0.03 & 0.02 & 0.02 & 0.14\\ +\bottomrule +\end{tabular} +\end{table} + +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-3-1.pdf} + +\section{Plots for each Performance} +\label{appendixd} + +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-1.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-2.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-3.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-4.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-5.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-6.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-7.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-8.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-9.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-10.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-11.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-12.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-13.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-14.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-15.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-16.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-17.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-18.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-19.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-20.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-21.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-22.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-23.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-24.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-25.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-26.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-27.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-28.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-29.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-30.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-31.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-32.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-33.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-34.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-35.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-36.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-37.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-38.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-39.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-40.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-41.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-42.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-43.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-44.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-45.pdf} +\includegraphics{Dynamics-Model_files/figure-latex/unnamed-chunk-4-46.pdf} + +\bibliographystyle{agsm} +\bibliography{musicdynamicsbib.bib} + +\end{document} diff --git a/manuscript/dynamicspaper/agsm.bst b/manuscript/dynamicspaper/agsm.bst new file mode 100644 index 0000000..9ebcc9c --- /dev/null +++ b/manuscript/dynamicspaper/agsm.bst @@ -0,0 +1,1353 @@ +% BibTeX standard bibliography style `agsm' (one of the harvard family) + % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09. + % Copyright (C) 1991, all rights reserved. + % Copying of this file is authorized only if either + % (1) you make absolutely no changes to your copy, including name, or + % (2) if you do make changes, you name it something other than + % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, abbrv.bst, agsm.bst, + % dcu.bst or kluwer.bst. + % This restriction helps ensure that all standard styles are identical. + % The file harvard.tex has the documentation for this style. + +% ACKNOWLEDGEMENT: +% This document is a modified version of alpha.bst to which it owes much of +% its functionality. + +% AUTHOR +% Peter Williams, Key Centre for Design Quality, Sydney University +% e-mail: peterw@archsci.arch.su.oz.au + +ENTRY + { address + author + booktitle + chapter + edition + editor + howpublished + institution + journal + key + month + note + number + organization + pages + publisher + school + series + title + type + URL + volume + year + } + { field.used etal.allowed etal.required} %%%XXX change + { extra.label sort.label list.year } + +INTEGERS { output.state before.all mid.sentence after.sentence after.block } + +FUNCTION {init.state.consts} +{ #0 'before.all := + #1 'mid.sentence := + #2 'after.sentence := + #3 'after.block := +} + +STRINGS { s t f } + +FUNCTION {output.nonnull} +{ 's := + output.state mid.sentence = + { ", " * write$ } + { output.state after.block = + { add.period$ write$ + newline$ + "\newblock " write$ + } + { output.state before.all = + 'write$ + { add.period$ " " * write$ } + if$ + } + if$ + mid.sentence 'output.state := + } + if$ + s +} + +FUNCTION {output} +{ duplicate$ empty$ + 'pop$ + 'output.nonnull + if$ +} + +FUNCTION {output.check} +{ 't := + duplicate$ empty$ + { pop$ "empty " t * " in " * cite$ * warning$ } + 'output.nonnull + if$ +} + +FUNCTION {item.check} +{ 't := + empty$ + { "empty " t * " in " * cite$ * warning$ } + { skip$ } + if$ +} + +FUNCTION {fin.entry} +{ add.period$ + write$ + newline$ +} + +FUNCTION {new.block} +{ output.state before.all = + 'skip$ + { after.block 'output.state := } + if$ +} + +FUNCTION {not} +{ { #0 } + { #1 } + if$ +} + +FUNCTION {and} +{ 'skip$ + { pop$ #0 } + if$ +} + +FUNCTION {or} +{ { pop$ #1 } + 'skip$ + if$ +} + +FUNCTION {field.or.null} +{ duplicate$ empty$ + { pop$ "" } + 'skip$ + if$ +} + +FUNCTION {emphasize} +{ duplicate$ empty$ + { pop$ "" } + { "{\em " swap$ * "}" * } + if$ +} + +FUNCTION {embolden} +{ duplicate$ empty$ + { pop$ "" } + { "{\bf " swap$ * "}" * } + if$ +} + +FUNCTION {quote} +{ duplicate$ empty$ + { pop$ "" } + { "`" swap$ * "'" * } + if$ +} + +FUNCTION {write.url} +{ URL empty$ + { skip$ } + { "\newline\harvardurl{" URL * "}" * write$ newline$ } + if$ +} + +INTEGERS { nameptr namesleft numnames } + +FUNCTION {format.names} +{ 's := + 'f := + #1 'nameptr := + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { s nameptr f format.name$ 't := + nameptr #1 > + { namesleft #1 > + { ", " * t * } + { t "others" = + { " et~al." * } + { " \harvardand\ " * t * } + if$ + } + if$ + } + 't + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +FUNCTION {format.authors} +{ author empty$ + { "" } + { "{vv~}{ll}{, jj}{, f.}" author format.names } + if$ +} + +FUNCTION {format.editors} +{ editor empty$ + { "" } + { "{vv~}{ll}{, jj}{, f.}" editor format.names + editor num.names$ #1 > + { ", eds" * } + { ", ed." * } + if$ + } + if$ +} + +FUNCTION {format.editors.reverse} +{ editor empty$ + { "" } + { "{f.~}{vv~}{ll}{, jj}" editor format.names + editor num.names$ #1 > + { ", eds" * } + { ", ed." * } + if$ + } + if$ +} + +FUNCTION {format.title} +{ title empty$ + { "" } + { title "t" change.case$ } + if$ +} + +FUNCTION {n.dashify} +{ 't := + "" + { t empty$ not } + { t #1 #1 substring$ "-" = + { t #1 #2 substring$ "--" = not + { "--" * + t #2 global.max$ substring$ 't := + } + { { t #1 #1 substring$ "-" = } + { "-" * + t #2 global.max$ substring$ 't := + } + while$ + } + if$ + } + { t #1 #1 substring$ * + t #2 global.max$ substring$ 't := + } + if$ + } + while$ +} + +FUNCTION {format.btitle} +{ title emphasize +} + +FUNCTION {tie.or.space.connect} +{ duplicate$ text.length$ #3 < + { "~" } + { " " } + if$ + swap$ * * +} + +FUNCTION {either.or.check} +{ empty$ + 'pop$ + { "can't use both " swap$ * " fields in " * cite$ * warning$ } + if$ +} + +FUNCTION {format.bvolume} +{ volume empty$ + { "" } + { "Vol." volume tie.or.space.connect + series empty$ + 'skip$ + { " of " * series emphasize * } + if$ + "volume and number" number either.or.check + } + if$ +} + +FUNCTION {format.number.series} +{ volume empty$ + { number empty$ + { series field.or.null } + { output.state mid.sentence = + { "number" } + { "Number" } + if$ + number tie.or.space.connect + series empty$ + { "there's a number but no series in " cite$ * warning$ } + { " {\em in} " * series quote * } + if$ + } + if$ + } + { "" } + if$ +} + +FUNCTION {format.edition} +{ edition empty$ + { "" } + { output.state mid.sentence = + { edition "l" change.case$ " edn" * } + { edition "t" change.case$ " edn" * } + if$ + } + if$ +} + +INTEGERS { multiresult } + +FUNCTION {multi.page.check} +{ 't := + #0 'multiresult := + { multiresult not + t empty$ not + and + } + { t #1 #1 substring$ + duplicate$ "-" = + swap$ duplicate$ "," = + swap$ "+" = + or or + { #1 'multiresult := } + { t #2 global.max$ substring$ 't := } + if$ + } + while$ + multiresult +} + +FUNCTION {format.pages} +{ pages empty$ + { "" } + { pages multi.page.check + { "pp.~" pages n.dashify * } + { "p.~" pages * } + if$ + } + if$ +} + +FUNCTION {format.vol.num.pages} +{ volume embolden field.or.null + number empty$ + 'skip$ + { "(" number * ")" * * + volume empty$ + { "there's a number but no volume in " cite$ * warning$ } + 'skip$ + if$ + } + if$ + pages empty$ + 'skip$ + { duplicate$ empty$ + { pop$ format.pages } + { ",~" * pages n.dashify * } + if$ + } + if$ +} + +FUNCTION {format.chapter.pages} +{ chapter empty$ + 'format.pages + { type empty$ + { "chapter" } + { type "l" change.case$ } + if$ + chapter tie.or.space.connect + pages empty$ + 'skip$ + { ", " * format.pages * } + if$ + } + if$ +} + +FUNCTION {format.in.ed.booktitle} +{ booktitle empty$ + { "" } + { editor empty$ + { "{\em in} " booktitle quote * } + { "{\em in} " format.editors.reverse * ", " * booktitle quote * } + if$ + } + if$ +} + +FUNCTION {empty.misc.check} +{ author empty$ title empty$ howpublished empty$ + month empty$ year empty$ note empty$ + and and and and and + key empty$ not and + { "all relevant fields are empty in " cite$ * warning$ } + 'skip$ + if$ +} + +FUNCTION {format.thesis.type} +{ type empty$ + 'skip$ + { pop$ + type "t" change.case$ + } + if$ +} + +FUNCTION {format.tr.number} +{ type empty$ + { "Technical Report" } + 'type + if$ + number empty$ + { "t" change.case$ } + { number tie.or.space.connect } + if$ +} + +FUNCTION {format.article.crossref} +{ key empty$ + { journal empty$ + { "need key or journal for " cite$ * " to crossref " * crossref * + warning$ + "" + } + { "in {\em " journal * "\/} \cite{" * crossref * "}" *} + if$ + } + { "{\em in} \citeasnoun{" crossref * "}" * } + if$ + +} + +FUNCTION {format.book.crossref} +{ volume empty$ + { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ + "in " + } + { "Vol." volume tie.or.space.connect + " of " * + } + if$ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { series empty$ + { "need editor, key, or series for " cite$ * " to crossref " * + crossref * warning$ + "" * + } + { "{\em " * series * "\/} \cite{" * crossref * "}" *} + if$ + } + { " \citeasnoun{" * crossref * "}" * } + if$ + } + { " \citeasnoun{" * crossref * "}" * } + if$ +} + +FUNCTION {format.incoll.inproc.crossref} +{ editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { booktitle empty$ + { "need editor, key, or booktitle for " cite$ * " to crossref " * + crossref * warning$ + "" + } + { "in {\em " booktitle * "\/}" * " \cite{" * crossref * "}" *} + if$ + } + { "{\em in} \citeasnoun{" crossref * "}" * } + if$ + } + { "{\em in} \citeasnoun{" crossref * "}" * } + if$ + +} + +INTEGERS { len } + +FUNCTION {chop.word} +{ 's := + 'len := + s #1 len substring$ = + { s len #1 + global.max$ substring$ } + 's + if$ +} + +INTEGERS { ind tsslen } + +STRINGS { tss ret rss istr } + +FUNCTION {replace.substring}{ + 'rss := + 'tss := + 'istr := + "" 'ret := + tss text.length$ 'tsslen := + #1 'ind := + { istr ind tsslen substring$ "" = not } + { istr ind tsslen substring$ tss = + { ret rss * 'ret := + ind tsslen + 'ind := + } + { ret istr ind #1 substring$ * 'ret := + ind #1 + 'ind := + } + if$ + } + while$ + ret +} + +FUNCTION {format.lab.names.abbr} +{ 's := + s num.names$ 'numnames := + numnames #1 > + { numnames #2 > + { s #1 "{vv~}{ll}" format.name$ " et~al." * } + { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = + { s #1 "{vv~}{ll}" format.name$ " et~al." * } + { s #1 "{vv~}{ll}" format.name$ " \harvardand\ " * + s #2 "{vv~}{ll}" format.name$ * + } + if$ + } + if$ + } + { s #1 "{vv~}{ll}" format.name$ } + if$ +} + +FUNCTION {format.lab.names.full} +{ 's := + #1 'nameptr := + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { s nameptr "{vv~}{ll}" format.name$ 't := + nameptr #1 > + { namesleft #1 > + { ", " * t * } + { t "others" = + { " et~al." * } + { " \harvardand\ " * t * } + if$ + } + if$ + } + 't + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +INTEGERS { author.field editor.field organization.field title.field key.field } + +FUNCTION {init.field.constants} +{ #0 'author.field := + #1 'editor.field := + #2 'organization.field := + #3 'title.field := + #4 'key.field := +} + +FUNCTION {make.list.label} +{ author.field field.used = + { format.authors } + { editor.field field.used = + { format.editors } + { organization.field field.used = + { "The " #4 organization chop.word #3 text.prefix$ } + { title.field field.used = + { format.btitle } + { key.field field.used = + { key #3 text.prefix$ } + { "Internal error :001 on " cite$ * " label" * warning$ } + if$ + } + if$ + } + if$ + } + if$ + } + if$ +} + +FUNCTION {make.full.label} +{ author.field field.used = + { author format.lab.names.full } + { editor.field field.used = + { editor format.lab.names.full } + { organization.field field.used = + { "The " #4 organization chop.word #3 text.prefix$ } + { title.field field.used = + { format.btitle } + { key.field field.used = + { key #3 text.prefix$ } + { "Internal error :001 on " cite$ * " label" * warning$ } + if$ + } + if$ + } + if$ + } + if$ + } + if$ +} + +FUNCTION {make.abbr.label} %%%XXX change +{ + etal.allowed + { author.field field.used = + { author format.lab.names.abbr } + { editor.field field.used = + { editor format.lab.names.abbr } + { organization.field field.used = + { "The " #4 organization chop.word #3 text.prefix$ } + { title.field field.used = + { format.btitle } + { key.field field.used = + { key #3 text.prefix$ } + {"Internal error :001 on " cite$ * " label" * warning$ } + if$ + } + if$ + } + if$ + } + if$ + } + if$ + } + { make.full.label } + if$ +} + +FUNCTION {output.bibitem} +{ newline$ + etal.allowed %%%XXX change + etal.required + and + { + "\harvarditem[" write$ + make.abbr.label write$ + "]{" write$ + } + { + "\harvarditem{" write$ + } + if$ + make.full.label write$ + "}{" write$ + list.year write$ + "}{" write$ + cite$ write$ + "}" write$ + newline$ + "" + before.all 'output.state := +} + +FUNCTION {list.label.output} +{ make.list.label " " * write$ +} + +FUNCTION {article} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author "author" item.check + title.field field.used = + { skip$ } + { format.title quote "title" output.check } + if$ + crossref missing$ + { journal emphasize "journal" duplicate$ item.check + " " * format.vol.num.pages * output + } + { format.article.crossref output.nonnull + format.pages output + } + if$ + new.block + note output + fin.entry + write.url +} + +FUNCTION {book} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author empty$ + { editor "author and editor" item.check } + { crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + title.field field.used = + { skip$ } + { format.btitle "title" output.check } + if$ + crossref missing$ + { format.bvolume output + format.number.series output + format.edition output + publisher "publisher" output.check + address output + } + { format.book.crossref output.nonnull + format.edition output + } + if$ + new.block + note output + fin.entry + write.url +} + +FUNCTION {booklet} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.title quote "title" output.check } + if$ + howpublished output + address output + new.block + note output + fin.entry + write.url +} + +FUNCTION {inbook} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author empty$ + { editor "author and editor" item.check } + { crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + title.field field.used = + { skip$ } + { format.btitle "title" output.check } + if$ + crossref missing$ + { format.bvolume output + format.number.series output + format.edition output + publisher "publisher" output.check + address output + } + { format.book.crossref output.nonnull + format.edition output + } + if$ + format.chapter.pages "chapter and pages" output.check + new.block + note output + fin.entry + write.url +} + +FUNCTION {incollection} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.title "title" output.check } + if$ + author "author" item.check + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.edition output + format.bvolume output + format.number.series output + publisher "publisher" output.check + address output + } + { format.incoll.inproc.crossref output.nonnull + } + if$ + format.chapter.pages output + new.block + note output + fin.entry + write.url +} + +FUNCTION {inproceedings} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.title "title" output.check } + if$ + author "author" item.check + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.bvolume output + format.number.series output + address empty$ + { organization output + publisher output + } + { organization output + publisher output + address output.nonnull + } + if$ + } + { format.incoll.inproc.crossref output.nonnull + } + if$ + format.pages output + new.block + note output + fin.entry + write.url +} + +FUNCTION {conference} { inproceedings } + +FUNCTION {manual} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.btitle "title" output.check } + if$ + format.edition output + author empty$ + { organization empty$ + { address output } + 'skip$ + if$ + } + { organization output + address output + } + if$ + new.block + note output + fin.entry + write.url +} + +FUNCTION {mastersthesis} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author "author" item.check + title.field field.used = + { skip$ } + { format.title "title" output.check } + if$ + "Master's thesis" format.thesis.type output.nonnull + school "school" output.check + address output + new.block + note output + fin.entry + write.url +} + +FUNCTION {misc} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.title quote output } + if$ + howpublished output + new.block + note output + fin.entry + write.url + empty.misc.check +} + +FUNCTION {phdthesis} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author "author" item.check + title.field field.used = + { skip$ } + { title "title" output.check } + if$ + "PhD thesis" format.thesis.type output.nonnull + school "school" output.check + address output + new.block + note output + fin.entry + write.url +} + +FUNCTION {proceedings} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + title.field field.used = + { skip$ } + { format.btitle "title" output.check } + if$ + format.bvolume output + format.number.series output + address empty$ + { editor empty$ + { skip$ } + { organization output + } + if$ + publisher output + } + { editor empty$ + 'skip$ + { organization output } + if$ + publisher output + address output.nonnull + } + if$ + new.block + note output + fin.entry + write.url +} + +FUNCTION {techreport} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author "author" item.check + title.field field.used = + { skip$ } + { format.title "title" output.check } + if$ + format.tr.number output.nonnull + institution "institution" output.check + address output + new.block + note output + fin.entry + write.url +} + +FUNCTION {unpublished} +{ output.bibitem + list.label.output + " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull + author "author" item.check + title.field field.used = + { skip$ } + { format.title "title" output.check } + if$ + new.block + note "note" output.check + fin.entry + write.url +} + +FUNCTION {default.type} { misc } + +MACRO {jan} {"January"} + +MACRO {feb} {"February"} + +MACRO {mar} {"March"} + +MACRO {apr} {"April"} + +MACRO {may} {"May"} + +MACRO {jun} {"June"} + +MACRO {jul} {"July"} + +MACRO {aug} {"August"} + +MACRO {sep} {"September"} + +MACRO {oct} {"October"} + +MACRO {nov} {"November"} + +MACRO {dec} {"December"} + +MACRO {acmcs} {"ACM Computing Surveys"} + +MACRO {acta} {"Acta Informatica"} + +MACRO {cacm} {"Communications of the ACM"} + +MACRO {ibmjrd} {"IBM Journal of Research and Development"} + +MACRO {ibmsj} {"IBM Systems Journal"} + +MACRO {ieeese} {"IEEE Transactions on Software Engineering"} + +MACRO {ieeetc} {"IEEE Transactions on Computers"} + +MACRO {ieeetcad} + {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"} + +MACRO {ipl} {"Information Processing Letters"} + +MACRO {jacm} {"Journal of the ACM"} + +MACRO {jcss} {"Journal of Computer and System Sciences"} + +MACRO {scp} {"Science of Computer Programming"} + +MACRO {sicomp} {"SIAM Journal on Computing"} + +MACRO {tocs} {"ACM Transactions on Computer Systems"} + +MACRO {tods} {"ACM Transactions on Database Systems"} + +MACRO {tog} {"ACM Transactions on Graphics"} + +MACRO {toms} {"ACM Transactions on Mathematical Software"} + +MACRO {toois} {"ACM Transactions on Office Information Systems"} + +MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"} + +MACRO {tcs} {"Theoretical Computer Science"} + +READ + +EXECUTE {init.field.constants} + +FUNCTION {sortify} +{ purify$ + "l" change.case$ +} + +FUNCTION {sortify.names} +{ " \harvardand\ " " " replace.substring + " et~al." " zzz" replace.substring + sortify +} + +FUNCTION {author.key.label} +{ author empty$ + { key empty$ + { title.field 'field.used := } + { key.field 'field.used := } + if$ + } + { author.field 'field.used := } + if$ +} + +FUNCTION {author.editor.key.label} +{ author empty$ + { editor empty$ + { key empty$ + { title.field 'field.used := } + { key.field 'field.used := } + if$ + } + { editor.field 'field.used := } + if$ + } + { author.field 'field.used := } + if$ +} + +FUNCTION {author.key.organization.label} +{ author empty$ + { key empty$ + { organization empty$ + { title.field 'field.used := } + { organization.field 'field.used := } + if$ + } + { key.field 'field.used := } + if$ + } + { author.field 'field.used := } + if$ +} + +FUNCTION {editor.key.organization.label} +{ editor empty$ + { key empty$ + { organization empty$ + { title.field 'field.used := } + { organization.field 'field.used := } + if$ + } + { key.field 'field.used := } + if$ + } + { editor.field 'field.used := } + if$ +} + +FUNCTION {sort.format.title} +{ 't := + "A " #2 + "An " #3 + "The " #4 t chop.word + chop.word + chop.word + sortify + #1 global.max$ substring$ +} + +FUNCTION {calc.label} %%%XXX change +{ make.abbr.label + title.field field.used = + { sort.format.title } + { sortify.names } + if$ + year field.or.null purify$ #-1 #4 substring$ sortify + * + 'sort.label := +} + +FUNCTION {preliminaries} %%%XXX change +{ type$ "book" = + type$ "inbook" = + or + 'author.editor.key.label + { type$ "proceedings" = + 'editor.key.organization.label + { type$ "manual" = + 'author.key.organization.label + 'author.key.label + if$ + } + if$ + } + if$ + author.field field.used = %%%XXX change + { + author num.names$ #2 > + { #1 } + { #0 } + if$ + 'etal.required := + } + { + editor.field field.used = + { + editor num.names$ #2 > + { #1 } + { #0 } + if$ + } + { #0 } + if$ + 'etal.required := + } + if$ + #1 'etal.allowed := +} + +FUNCTION {first.presort} +{ calc.label + sort.label + title.field field.used = + { skip$ } + { " " + * + make.list.label sortify.names + * + " " + * + title field.or.null + sort.format.title + * + } + if$ + #1 entry.max$ substring$ + 'sort.key$ := +} + +ITERATE {preliminaries} + +ITERATE {first.presort} + +SORT + +STRINGS { last.sort.label next.extra last.full.label} + +INTEGERS { last.extra.num last.etal.allowed} + +FUNCTION {initialize.confusion} +{ #0 int.to.chr$ 'last.sort.label := + #0 int.to.chr$ 'last.full.label := + #1 'last.etal.allowed := +} + +FUNCTION {confusion.pass} +{ last.sort.label sort.label = + { last.etal.allowed + { last.full.label make.full.label sortify.names = + { skip$ } + { #0 'etal.allowed := + #0 'last.etal.allowed := + } + if$ + } + { #0 'etal.allowed := } + if$ + } + { sort.label 'last.sort.label := + make.full.label sortify.names 'last.full.label := + #1 'last.etal.allowed := + } + if$ +} + +EXECUTE {initialize.confusion} + +ITERATE {confusion.pass} + +EXECUTE {initialize.confusion} + +REVERSE {confusion.pass} + +FUNCTION {initialize.last.extra.num} +{ #0 int.to.chr$ 'last.sort.label := + "" 'next.extra := + #0 'last.extra.num := +} + +FUNCTION {forward.pass} +{ last.sort.label sort.label = + { last.extra.num #1 + 'last.extra.num := + last.extra.num int.to.chr$ 'extra.label := + } + { "a" chr.to.int$ 'last.extra.num := + "" 'extra.label := + sort.label 'last.sort.label := + } + if$ +} + +FUNCTION {reverse.pass} +{ next.extra "b" = + { "a" 'extra.label := } + 'skip$ + if$ + year empty$ + { "n.d." extra.label emphasize * 'list.year := } + { year extra.label emphasize * 'list.year := } + if$ + extra.label 'next.extra := +} + +ITERATE {first.presort} + +SORT + +EXECUTE {initialize.last.extra.num} + +ITERATE {forward.pass} + +REVERSE {reverse.pass} + +FUNCTION {second.presort} +{ make.list.label + title.field field.used = + { sort.format.title } + { sortify.names } + if$ + " " + * + list.year field.or.null sortify + * + " " + * + title.field field.used = + { skip$ } + { title field.or.null + sort.format.title + * + } + if$ + #1 entry.max$ substring$ + 'sort.key$ := +} + +ITERATE {second.presort} + +SORT + +FUNCTION {begin.bib} +{ preamble$ empty$ + 'skip$ + { "\harvardpreambledefs{%" write$ newline$ + preamble$ write$ "}" write$ newline$ + "\harvardpreambletext{%" write$ newline$ + preamble$ write$ "}" write$ newline$ } + if$ + "\begin{thebibliography}{xx}" write$ newline$ +} + +EXECUTE {begin.bib} + +EXECUTE {init.state.consts} + +ITERATE {call.type$} + +FUNCTION {end.bib} +{ newline$ + "\end{thebibliography}" write$ newline$ +} + +EXECUTE {end.bib} diff --git a/manuscript/dynamicspaper/mazurkaDynamicsResults.Rdata b/manuscript/dynamicspaper/mazurkaDynamicsResults.Rdata new file mode 100644 index 0000000..b555e07 Binary files /dev/null and b/manuscript/dynamicspaper/mazurkaDynamicsResults.Rdata differ diff --git a/manuscript/dynamicspaper/mazurkaDynamicsResultsNEWPRIORS.Rdata b/manuscript/dynamicspaper/mazurkaDynamicsResultsNEWPRIORS.Rdata new file mode 100644 index 0000000..229efd8 Binary files /dev/null and b/manuscript/dynamicspaper/mazurkaDynamicsResultsNEWPRIORS.Rdata differ diff --git a/manuscript/dynamicspaper/mazurkaDynamicsResultsOLD.Rdata b/manuscript/dynamicspaper/mazurkaDynamicsResultsOLD.Rdata new file mode 100644 index 0000000..1ec8019 Binary files /dev/null and b/manuscript/dynamicspaper/mazurkaDynamicsResultsOLD.Rdata differ diff --git a/manuscript/dynamicspaper/musicdynamicsbib.bib b/manuscript/dynamicspaper/musicdynamicsbib.bib new file mode 100644 index 0000000..f6b8126 --- /dev/null +++ b/manuscript/dynamicspaper/musicdynamicsbib.bib @@ -0,0 +1,216 @@ + +@article{rauch_maximum_1965, + title = {Maximum likelihood estimates of linear dynamic systems}, + volume = {3}, + number = {8}, + journal = {AIAA journal}, + author = {Rauch, Herbert E and Striebel, CT and Tung, F}, + year = {1965}, + pages = {1445--1450} +} + +@book{charm_centre_2009, + title = {Centre for the {History} and {Analysis} of {Recorded} {Music}}, + url = {http://www.charm.rhul.ac.uk/about/about.html}, + author = {{CHARM}}, + year = {2009}, + annote = {Online; accessed 12 March 2019} +} + +@book{earis_mazurka_2009, + title = {Mazurka in {F} {Major}, {Op}. 68, {No}. 3}, + url = {http://mazurka.org.uk/auto/earis/mazurka68-3/}, + author = {Earis, Andrew}, + year = {2009}, + annote = {accessed 12 March 2019} +} + +@book{r_core_team_r_2019, + address = {Vienna, Austria}, + title = {R: {A} {Language} and {Environment} for {Statistical} {Computing}}, + url = {https://www.R-project.org/}, + publisher = {R Foundation for Statistical Computing}, + author = {{R Core Team}}, + year = {2019} +} + +@book{wickham_tidyverse_2017, + title = {tidyverse: {Easily} {Install} and {Load} the '{Tidyverse}'}, + url = {https://CRAN.R-project.org/package=tidyverse}, + author = {Wickham, Hadley}, + year = {2017}, + annote = {R package version 1.2.1} +} + +@book{wickham_ggplot2_2016, + edition = {2nd}, + title = {ggplot2: {Elegant} graphics for data analysis}, + publisher = {Springer}, + author = {Wickham, Hadley}, + year = {2016} +} + +@article{mcdonald_markov-switching_2019, + title = {Markov-switching {State} {Space} {Models} for {Uncovering} {Musical} {Interpretation}}, + url = {http://arxiv.org/abs/1907.06244}, + abstract = {For concertgoers, musical interpretation is the most important factor in determining whether or not we enjoy a classical performance. Every performance includes mistakes—intonation issues, a lost note, an unpleasant sound—but these are all easily forgotten (or unnoticed) when a performer engages her audience, imbuing a piece with novel emotional content beyond the vague instructions inscribed on the printed page. While music teachers use imagery or heuristic guidelines to motivate interpretive decisions, combining these vague instructions to create a convincing performance remains the domain of the performer, subject to the whims of the moment, technical fluency, and taste. In this research, we use data from the CHARM Mazurka Project—forty-six professional recordings of Chopin’s Mazurka Op. 63 No. 3 by consumate artists—with the goal of elucidating musically interpretable performance decisions. Using information on the inter-onset intervals of the note attacks in the recordings, we apply functional data analysis techniques enriched with prior information gained from music theory to discover relevant features and perform hierarchical clustering. The resulting clusters suggest methods for informing music instruction, discovering listening preferences, and analyzing performances.}, + urldate = {2019-09-30}, + journal = {arXiv:1907.06244 [stat]}, + author = {McDonald, Daniel J. and McBride, Michael and Gu, Yupeng and Raphael, Christopher}, + month = jul, + year = {2019}, + keywords = {Statistics - Applications, Statistics - Methodology}, + annote = {arXiv: 1907.06244}, + file = {McDonald et al. - 2019 - Markov-switching State Space Models for Uncovering.pdf:C\:\\Users\\Rob\\Zotero\\storage\\NY6KNJI3\\McDonald et al. - 2019 - Markov-switching State Space Models for Uncovering.pdf:application/pdf} +} + +@article{fearnhead_-line_2003, + title = {On-line inference for hidden {Markov} models via particle filters}, + volume = {65}, + issn = {1369-7412, 1467-9868}, + url = {http://doi.wiley.com/10.1111/1467-9868.00421}, + doi = {10.1111/1467-9868.00421}, + abstract = {We consider the on-line Bayesian analysis of data by using a hidden Markov model, where inference is tractable conditional on the history of the state of the hidden component. A new particle filter algorithm is introduced and shown to produce promising results when analysing data of this type. The algorithm is similar to the mixture Kalman filter but uses a different resampling algorithm. We prove that this resampling algorithm is computationally efficient and optimal, among unbiased resampling algorithms, in terms of minimizing a squared error loss function. In a practical example, that of estimating break points from well-log data, our new particle filter outperforms two other particle filters, one of which is the mixture Kalman filter, by between one and two orders of magnitude.}, + number = {4}, + urldate = {2019-10-31}, + journal = {Journal of the Royal Statistical Society: Series B (Statistical Methodology)}, + author = {Fearnhead, Paul and Clifford, Peter}, + month = nov, + year = {2003}, + pages = {887--899}, + file = {Fearnhead and Clifford - 2003 - On-line inference for hidden Markov models via par.pdf:C\:\\Users\\Rob\\Zotero\\storage\\F2NXMMWA\\Fearnhead and Clifford - 2003 - On-line inference for hidden Markov models via par.pdf:application/pdf} +} + +@article{gu_modeling_2012, + title = {{MODELING} {PIANO} {INTERPRETATION} {USING} {SWITCHING} {KALMAN} {FILTER}}, + abstract = {An approach of parsing piano music interpretation is presented. We focus mainly on quantifying expressive timing activities. A small number of different expressive timing behaviors (constant, slowing down, speeding up, accent) are defined in order to explain the tempo discretely. Given a MIDI performance of a piano music, we simultaneously estimate both discrete variables that corresponds to the behaviors and continuous variables that describe tempo. A graphical model is introduced to represent the evolution of the discrete behaviors and tempo progression. We demonstrate a computational method that acquires the approximate most likely configuration of the discrete behaviors and the hidden continuous variable tempo. This configuration represent a “smoothed” version of the performance which greatly reduces parametrization while retaining most of its musicality. Experiments are presented on several MIDI piano music performed on a digital piano. An user study is performed to evaluate our method.}, + journal = {13th International Society for Music Information Retrieval Conference}, + author = {Gu, Yupeng and Raphael, Christopher}, + year = {2012}, + file = {Gu and Raphael - 2012 - MODELING PIANO INTERPRETATION USING SWITCHING KALM.pdf:C\:\\Users\\Rob\\Zotero\\storage\\NGA5ZWVB\\Gu and Raphael - 2012 - MODELING PIANO INTERPRETATION USING SWITCHING KALM.pdf:application/pdf} +} + +@book{durbin_time_2012, + address = {Oxford}, + title = {Time {Series} {Analysis} by {State} {Space} {Methods}: {Second} {Edition}.}, + isbn = {978-0-19-162718-7}, + shorttitle = {Time {Series} {Analysis} by {State} {Space} {Methods}}, + url = {http://grail.eblib.com.au/patron/FullRecord.aspx?p=991963}, + abstract = {This new edition updates Durbin \& Koopman's important text on the state space approach to time series analysis. The distinguishing feature of state space time series models is that observations are regarded as made up of distinct components such as trend, seasonal, regression elements and disturbance terms, each of which is modelled separately. The techniques that emerge from this approach are very flexible and are capable of handling a much wider range of problems than themain analytical system currently in use for time series analysis, the Box-Jenkins ARIMA system. Additions to this second e.}, + urldate = {2020-03-02}, + publisher = {Oxford University Press}, + author = {Durbin, James and Koopman, Siem Jan}, + year = {2012}, + file = {Time_Series_Analysis_by_State_Space_Methods_Time_S..._----_(PART_I_THE_LINEAR_STATE_SPACE_MODEL).pdf:C\:\\Users\\Rob\\Zotero\\storage\\IAAH2UZS\\Time_Series_Analysis_by_State_Space_Methods_Time_S..._----_(PART_I_THE_LINEAR_STATE_SPACE_MODEL).pdf:application/pdf} +} + +@article{earis_algorithm_2007, + title = {An {Algorithm} to {Extract} {Expressive} {Timing} and {Dynamics} from {Piano} {Recordings}}, + volume = {11}, + issn = {1029-8649, 2045-4147}, + url = {http://journals.sagepub.com/doi/10.1177/102986490701100202}, + doi = {10.1177/102986490701100202}, + language = {en}, + number = {2}, + urldate = {2020-03-09}, + journal = {Musicae Scientiae}, + author = {Earis, Andrew}, + month = jul, + year = {2007}, + pages = {155--182}, + file = {Earis - 2007 - An Algorithm to Extract Expressive Timing and Dyna.pdf:C\:\\Users\\Rob\\Zotero\\storage\\UCIJUL8P\\Earis - 2007 - An Algorithm to Extract Expressive Timing and Dyna.pdf:application/pdf} +} + +@article{kalman_new_1960, + title = {A {New} {Approach} to {Linear} {Filtering} and {Prediction} {Problems1}}, + language = {en}, + journal = {Journal of Basic Engineering}, + author = {Kalman, R.E.}, + year = {1960}, + pages = {12}, + file = {Lukesh - 1960 - A New Approach to Linear Filtering and Prediction .pdf:C\:\\Users\\Rob\\Zotero\\storage\\9DCPTPGP\\Lukesh - 1960 - A New Approach to Linear Filtering and Prediction .pdf:application/pdf} +} + +@book{nash_optimr_2019, + title = {optimr: {A} {Replacement} and {Extension} of the 'optim' {Function}}, + url = {https://CRAN.R-project.org/package=optimr}, + author = {Nash, John C.}, + month = dec, + year = {2019} +} + +@book{mcdonald_dpf_2020, + title = {dpf: {Discrete} particle filtering}, + url = {https://github.com/dajmcdon/dpf}, + author = {McDonald, Daniel J.}, + year = {2020} +} + +@article{nelder_simplex_1965, + title = {A {Simplex} {Method} for {Function} {Minimization}}, + volume = {7}, + number = {4}, + journal = {The Computer Journal}, + author = {Nelder, J A and Mead, R}, + month = jan, + year = {1965}, + pages = {308--313} +} + +@article{tugnait_detection_1982, + title = {Detection and estimation for abruptly changing systems}, + volume = {18}, + number = {5}, + journal = {Automatica}, + author = {Tugnait, Jitendra A}, + year = {1982}, + pages = {607--615} +} + +@article{akashi_random_1977, + title = {Random sampling approach to state estimation in switching environments}, + volume = {13}, + number = {4}, + journal = {Automatica}, + author = {Akashi, Hajime and Kumamoto, Hiromitsu}, + month = jul, + year = {1977}, + pages = {429--434} +} + +@misc{spotify_spotify_2019, + title = {Spotify {Support}}, + url = {https://support.spotify.com/us/article/made-for-you-playlists/}, + urldate = {2020-06-01}, + author = {Spotify}, + month = dec, + year = {2019} +} + +@misc{kkbox_wsdm-kkboxs_2017, + title = {{WSDM}-{KKBox}'s {Music} {Recommendation} {Challenge}}, + url = {https://www.kaggle.com/c/kkbox-music-recommendation-challenge/data}, + urldate = {2020-06-01}, + journal = {Kaggle}, + author = {KKBox}, + month = dec, + year = {2017} +} + +@article{mcalone_exec_2017, + title = {The exec who replaced {Netflix}'s 5-star rating system with 'thumbs up, thumbs down' explains why}, + url = {https://www.businessinsider.com/why-netflix-replaced-its-5-star-rating-system-2017-4}, + urldate = {2020-06-01}, + journal = {Business Insider}, + author = {McAlone, Nathan}, + month = apr, + year = {2017} +} + +@misc{pandora_music_2020, + title = {Music {Genome} {Project}}, + url = {https://www.pandora.com/about/mgp}, + urldate = {2020-06-01}, + author = {Pandora}, + year = {2020} +} diff --git a/manuscript/.gitignore b/manuscript/tempopaper/.gitignore similarity index 100% rename from manuscript/.gitignore rename to manuscript/tempopaper/.gitignore diff --git a/manuscript/Chopin - Mazurka Op68No3.pdf b/manuscript/tempopaper/Chopin - Mazurka Op68No3.pdf similarity index 100% rename from manuscript/Chopin - Mazurka Op68No3.pdf rename to manuscript/tempopaper/Chopin - Mazurka Op68No3.pdf diff --git a/manuscript/jasa-reject/JASA_ACS_author_form.docx b/manuscript/tempopaper/JASA_ACS_author_form.docx similarity index 100% rename from manuscript/jasa-reject/JASA_ACS_author_form.docx rename to manuscript/tempopaper/JASA_ACS_author_form.docx diff --git a/manuscript/aoas/ims-sample.pdf b/manuscript/tempopaper/aoas/ims-sample.pdf old mode 100755 new mode 100644 similarity index 100% rename from manuscript/aoas/ims-sample.pdf rename to manuscript/tempopaper/aoas/ims-sample.pdf diff --git a/manuscript/aoas/ims-sample.tex b/manuscript/tempopaper/aoas/ims-sample.tex old mode 100755 new mode 100644 similarity index 97% rename from manuscript/aoas/ims-sample.tex rename to manuscript/tempopaper/aoas/ims-sample.tex index dcca64c..509a042 --- a/manuscript/aoas/ims-sample.tex +++ b/manuscript/tempopaper/aoas/ims-sample.tex @@ -1,517 +1,517 @@ -\documentclass[aoas,preprint]{imsart} - -\RequirePackage[OT1]{fontenc} -\RequirePackage{amsthm,amsmath} -\RequirePackage[numbers]{natbib} -\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref} - -% settings -%\pubyear{2005} -%\volume{0} -%\issue{0} -%\firstpage{1} -%\lastpage{8} -\arxiv{arXiv:0000.0000} - -\startlocaldefs -\numberwithin{equation}{section} -\theoremstyle{plain} -\newtheorem{thm}{Theorem}[section] -\endlocaldefs - -\begin{document} - -\begin{frontmatter} -\title{A Sample Document\thanksref{T1}} -\runtitle{A Sample Document} -\thankstext{T1}{Footnote to the title with the ``thankstext'' command.} - -\begin{aug} -\author{\fnms{First} \snm{Author}\thanksref{t1,t2,m1}\ead[label=e1]{first@somewhere.com}}, -\author{\fnms{Second} \snm{Author}\thanksref{t3,m1,m2}\ead[label=e2]{second@somewhere.com}} -\and -\author{\fnms{Third} \snm{Author}\thanksref{t1,m2} -\ead[label=e3]{third@somewhere.com} -\ead[label=u1,url]{http://www.foo.com}} - -\thankstext{t1}{Some comment} -\thankstext{t2}{First supporter of the project} -\thankstext{t3}{Second supporter of the project} -\runauthor{F. Author et al.} - -\affiliation{Some University\thanksmark{m1} and Another University\thanksmark{m2}} - -\address{Address of the First and Second authors\\ -Usually a few lines long\\ -\printead{e1}\\ -\phantom{E-mail:\ }\printead*{e2}} - -\address{Address of the Third author\\ -Usually a few lines long\\ -Usually a few lines long\\ -\printead{e3}\\ -\printead{u1}} -\end{aug} - -\begin{abstract} -The abstract should summarize the contents of the paper. -It should be clear, descriptive, self-explanatory and not longer -than 200 words. It should also be suitable for publication in -abstracting services. Please avoid using math formulas as much as possible. - -This is a sample input file. Comparing it with the output it -generates can show you how to produce a simple document of -your own. -\end{abstract} - -\begin{keyword}[class=MSC] -\kwd[Primary ]{60K35} -\kwd{60K35} -\kwd[; secondary ]{60K35} -\end{keyword} - -\begin{keyword} -\kwd{sample} -\kwd{\LaTeXe} -\end{keyword} - -\end{frontmatter} - -\section{Ordinary text} - -The ends of words and sentences are marked - by spaces. It doesn't matter how many -spaces you type; one is as good as 100. The -end of a line counts as a space. - -One or more blank lines denote the end -of a paragraph. - -Since any number of consecutive spaces are treated like a single -one, the formatting of the input file makes no difference to - \TeX, % The \TeX command generates the TeX logo. -but it makes a difference to you. -When you use - \LaTeX, % The \LaTeX command generates the LaTeX logo. -making your input file as easy to read as possible -will be a great help as you write your document and when you -change it. This sample file shows how you can add comments to -your own input file. - -Because printing is different from typewriting, there are a -number of things that you have to do differently when preparing -an input file than if you were just typing the document directly. -Quotation marks like - ``this'' -have to be handled specially, as do quotes within quotes: - ``\,`this' % \, separates the double and single quote. - is what I just - wrote, not `that.'\,'' - -Dashes come in three sizes: a hyphen, %an intra-word dash, -a medium dash for number ranges like - 1--2, -and a punctuation dash in place of a comma, semicolon, colon or parentheses - ---like -this. - -A sentence-ending space should be larger than the space between words -within a sentence. You sometimes have to type special commands in -conjunction with punctuation characters to get this right, as in the -following sentence. - Gnats, gnus, etc.\ % `\ ' makes an inter-word space. - all begin with G\@. % \@ marks end-of-sentence punctuation. -You should check the spaces after periods when reading your output to -make sure you haven't forgotten any special cases. -Generating an ellipsis - \ldots\ % `\ ' needed because TeX ignores spaces after - % command names like \ldots made from \ + letters. - % - % Note how a `%' character causes TeX to ignore the - % end of the input line, so these blank lines do not - % start a new paragraph. -with the right spacing around the periods -requires a special command. - -\TeX\ interprets some common characters as commands, so you must type -special commands to generate them. These characters include the -following: -% \$ - arXiv do not like it... - \& \% \# \{ and~\}. - -In printing, text is emphasized by using an - {\em italic\/} % The \/ command produces the tiny extra space that - % should be added between a slanted and a following - % unslanted letter. -type style. - -\begin{em} - A long segment of text can also be emphasized in this way. Text within - such a segment given additional emphasis - with\/ {\em Roman} - type. Italic type loses its ability to emphasize and become simply - distracting when used excessively. -\end{em} - -It is sometimes necessary to prevent \TeX\ from breaking a line where -it might otherwise do so. This may be at a space, as between the -``Mr.'' and ``Jones'' in - ``Mr.~Jones'', % ~ produces an unbreakable interword space. -or within a word---especially when the word is a symbol like - \mbox{\em itemnum\/} -that makes little sense when hyphenated across - lines. - -\TeX\ is good at typesetting mathematical formulas like - \( x-3y = 7 \) -or - \( a_{1} > x^{2n} / y^{2n} > x' \). -Remember that a letter like - $x$ % $ ... $ and \( ... \) are equivalent -is a formula when it denotes a mathematical symbol, and should -be treated as one. - - -\section{Notes} -Footnotes\footnote{This is an example of a footnote.} -pose no problem\footnote{And another one}. - -\section{Displayed text} - -Text is displayed by indenting it from the left margin. -Quotations are commonly displayed. There are short quotations -\begin{quote} - This is a short a quotation. It consists of a - single paragraph of text. There is no paragraph - indentation. -\end{quote} -and longer ones. -\begin{quotation} - This is a longer quotation. It consists of two paragraphs - of text. The beginning of each paragraph is indicated - by an extra indentation. - - This is the second paragraph of the quotation. It is just - as dull as the first paragraph. -\end{quotation} -Another frequently displayed structure is a list. -The following is an example of an {\em itemized} list, -four levels deep. -\begin{itemize} -\item This is the first item of an itemized list. Each item - in the list is marked with a ``tick.'' The document - style determines what kind of tick mark is used. -\item This is the second item of the list. It contains another - list nested inside it. The three inner lists are an {\em itemized} - list. - \begin{itemize} - \item This is the first item of an enumerated list that - is nested within the itemized list. - \item This is the second item of the inner list. \LaTeX\ - allows you to nest lists deeper than you really should. - \end{itemize} - This is the rest of the second item of the outer list. It - is no more interesting than any other part of the item. - \item This is the third item of the list. -\end{itemize} - - -The following is an example of an {\em enumerated} list, four levels deep. -\begin{enumerate} -\item This is the first item of an enumerated list. Each item - in the list is marked with a ``tick.'' The document - style determines what kind of tick mark is used. -\item This is the second item of the list. It contains another - list nested inside it. The three inner lists are an {\em enumerated} - list. - \begin{enumerate} - \item This is the first item of an enumerated list that - is nested within the enumerated list. - \item This is the second item of the inner list. \LaTeX\ - allows you to nest lists deeper than you really should. - \end{enumerate} - This is the rest of the second item of the outer list. It - is no more interesting than any other part of the item. - \item This is the third item of the list. -\end{enumerate} - - -The following is an example of a {\em description} list. -\begin{description} -\item[Cow] Highly intelligent animal that can produce milk out of grass. -\item[Horse] Less intelligent animal renowned for its legs. -\item[Human being] Not so intelligent animal convinced it can think. -\end{description} - -You can even display poetry. -\begin{verse} - There is an environment for verse \\ % The \\ command separates lines - Whose features some poets will curse. % within a stanza. - - % One or more blank lines separate stanzas. - - For instead of making\\ - Them do {\em all\/} line breaking, \\ - It allows them to put too many words on a line when they'd - rather be forced to be terse. -\end{verse} - -Mathematical formulas may also be displayed. A displayed formula is -one-line long: - - \[ x' + y^{2} = z_{i}^{2};\] - -multiline formulas require special formatting -instructions. - -Don't start a paragraph with a displayed equation, nor make -one a paragraph by itself. - -Example of a theorem: - - -\begin{thm} -All conjectures are interesting, but some conjectures are more -interesting than others. -\end{thm} - -\begin{proof} -Obvious. -\end{proof} - -\section{Tables and figures} -Cross reference to labeled table: As you can see in Table~\ref{sphericcase} on -page~\pageref{sphericcase} and also in Table~\ref{parset} on page~\pageref{parset}. - - -\begin{table*} -\caption{The spherical case ($I_1=0$, $I_2=0$)} -\label{sphericcase} -\begin{tabular}{crrrrc} -\hline -Equil. \\ -Points & \multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$y$} & \multicolumn{1}{c}{$z$} & \multicolumn{1}{c}{$C$} & -S \\ -\hline -$~~L_1$ & $-$2.485252241 & 0.000000000 & 0.017100631 & 8.230711648 & U \\ -$~~L_2$ & 0.000000000 & 0.000000000 & 3.068883732 & 0.000000000 & S \\ -$~~L_3$ & 0.009869059 & 0.000000000 & 4.756386544 & $-$0.000057922 & U \\ -$~~L_4$ & 0.210589855 & 0.000000000 & $-$0.007021459 & 9.440510897 & U \\ -$~~L_5$ & 0.455926604 & 0.000000000 & $-$0.212446624 & 7.586126667 & U \\ -$~~L_6$ & 0.667031314 & 0.000000000 & 0.529879957 & 3.497660052 & U \\ -$~~L_7$ & 2.164386674 & 0.000000000 & $-$0.169308438 & 6.866562449 & U \\ -$~~L_8$ & 0.560414471 & 0.421735658 & $-$0.093667445 & 9.241525367 & U \\ -$~~L_9$ & 0.560414471 & $-$0.421735658 & $-$0.093667445 & 9.241525367 & U -\\ -$~~L_{10}$ & 1.472523232 & 1.393484549 & $-$0.083801333 & 6.733436505 & U \\ -$~~L_{11}$ & 1.472523232 & $-$1.393484549 & $-$0.083801333 & 6.733436505 & U -\\ \hline -\end{tabular} -\end{table*} - - -A major -point of difference lies in the value of the specific production rate $\pi$ for -large values of the specific growth rate $\mu$. -Already in the early publications \cite{r1,r2,r3} -it appeared that high glucose -concentrations in the production phase are well correlated with a -low penicillin yield (the -``glucose effect''). It has been confirmed recently -\cite{r1,r2,r3,r4} -that -high glucose concentrations inhibit the synthesis of the enzymes of the -penicillin pathway, but not the actual penicillin biosynthesis. -In other words, glucose represses (and not inhibits) the penicillin -biosynthesis. - -These findings do not contradict the results of -\cite{r1} and of \cite{r4} which were obtained for -continuous culture fermentations. -Because for high values of the specific -growth rate $\mu$ it is most likely (as shall be discussed below) that -maintenance metabolism occurs, it can be shown that -in steady state continuous culture conditions, and with $\mu$ described by a Monod kinetics -\begin{equation} - C_{s} = K_{M} \frac{\mu/\mu_{x}}{1-\mu/\mu_{x}} \label{cs} -\end{equation} -Pirt \& Rhigelato determined $\pi$ for $\mu$ between -$0.023$ and $0.086$ h$^{-1}$. -They also reported a value $\mu_{x} \approx 0.095$ -h$^{-1}$, so that for their experiments $\mu/\mu_{x}$ is in the range -of $0.24$ to $0.9$. -Substituting $K _M$ in equation (\ref{cs}) by -the value $K_{M}=1$ g/L as used by \cite{r1}, one finds -with the above equation $0.3 < C_{s} < 9$ g/L. This agrees with -the work of \cite{r4}, who reported that penicillin biosynthesis -repression only occurs at glucose concentrations from $C_{s}=10$ g/L on. -The conclusion is that the glucose concentrations in the experiments of -Pirt \& Rhigelato probably were too low for glucose repression to be -detected. The experimental data published by Ryu \& Hospodka -are not detailed sufficiently to permit a similar analysis. - -\begin{table} -\centering -\caption{Parameter sets used by Bajpai \& Reu\ss\ }\label{parset} -\begin{tabular}{lrll} -\hline -\multicolumn{2}{l}{\it parameter} & {\it Set 1} & {\it Set 2}\\ -\hline -$\mu_{x}$ & [h$^{-1}$] & 0.092 & 0.11 \\ -$K_{x}$ & [g/g DM] & 0.15 & 0.006 \\ -$\mu_{p}$ & [g/g DM h] & 0.005 & 0.004 \\ -$K_{p}$ & [g/L] & 0.0002 & 0.0001 \\ -$K_{i}$ & [g/L] & 0.1 & 0.1 \\ -$Y_{x/s}$ & [g DM/g] & 0.45 & 0.47 \\ -$Y_{p/s}$ & [g/g] & 0.9 & 1.2 \\ -$k_{h}$ & [h$^{-1}$] & 0.04 & 0.01 \\ -$m_{s}$ & [g/g DM h] & 0.014 & 0.029 \\ -\hline -\end{tabular} -\end{table} - -Bajpai \& Reu\ss\ decided to disregard the -differences between time constants for the two regulation mechanisms -(glucose repression or inhibition) because of the -relatively very long fermentation times, and therefore proposed a Haldane -expression for $\pi$. - -It is interesting that simulations with the \cite{r4} model for the -initial conditions given by these authors indicate that, when the -remaining substrate is fed at a constant rate, a considerable and -unrealistic amount of penicillin is -produced when the glucose concentration is still very high \cite{r2,r3,r4} -Simulations with the Bajpai \& Reu\ss\ model correctly predict almost -no penicillin production in similar conditions. - -\begin{figure} % figuur 1 -\vspace{6pc} -\caption[]{Pathway of the penicillin G biosynthesis.} -\label{penG} -\end{figure} - -Sample of cross-reference to figure. -Figure~\ref{penG} shows that is not easy to get something on paper. - - - -\section{Headings} - -\subsection{Subsection} -Carr--Goldstein based their model on balancing methods and -biochemical know\-ledge. The original model (1980) contained an equation for the -oxygen dynamics which has been omitted in a second paper -(1981). This simplified model shall be discussed here. - -\subsubsection{Subsubsection} -Carr--Goldstein -based their model on balancing methods and -biochemical know\-ledge. The original model (1980) contained an equation for the -oxygen dynamics which has been omitted in a second paper -(1981). This simplified model shall be discussed here. - -\section{Equations and the like} - -Two equations: -\begin{equation} - C_{s} = K_{M} \frac{\mu/\mu_{x}}{1-\mu/\mu_{x}} \label{ccs} -\end{equation} -and -\begin{equation} - G = \frac{P_{\rm opt} - P_{\rm ref}}{P_{\rm ref}} \mbox{\ }100 \mbox{\ }(\%). -\end{equation} - -Two equation arrays: - -\begin{eqnarray} - \frac{dS}{dt} & = & - \sigma X + s_{F} F\\ - \frac{dX}{dt} & = & \mu X\\ - \frac{dP}{dt} & = & \pi X - k_{h} P\\ - \frac{dV}{dt} & = & F -\end{eqnarray} -and -\begin{eqnarray} - \mu_{\rm substr} & = & \mu_{x} \frac{C_{s}}{K_{x}C_{x}+C_{s}} \\ - \mu & = & \mu_{\rm substr} - Y_{x/s}(1-H(C_{s}))(m_{s}+\pi /Y_{p/s}) \\ - \sigma & = & \mu_{\rm substr}/Y_{x/s}+ H(C_{s}) (m_{s}+ \pi /Y_{p/s}). -\end{eqnarray} - - -\appendix - -\section{Appendix section}\label{app} - -We consider a sequence of queueing systems -indexed by $n$. It is assumed that each system -is composed of $J$ stations, indexed by $1$ -through $J$, and $K$ customer classes, indexed -by $1$ through $K$. Each customer class -has a fixed route through the network of -stations. Customers in class -$k$, $k=1,\ldots,K$, arrive to the -system according to a -renewal process, independently of the arrivals -of the other customer classes. These customers -move through the network, never visiting a station -more than once, until they eventually exit -the system. - -\subsection{Appendix subsection} - -However, different customer classes may visit -stations in different orders; the system -is not necessarily ``feed-forward.'' -We define the {\em path of class $k$ customers} in -as the sequence of servers -they encounter along their way through the network -and denote it by -\begin{equation} -\mathcal{P}=\bigl(j_{k,1},j_{k,2},\dots,j_{k,m(k)}\bigr). \label{path} -\end{equation} - -Sample of cross-reference to the formula \ref{path} in Appendix \ref{app}. - -\section*{Acknowledgements} -And this is an acknowledgements section with a heading that was produced by the -$\backslash$section* command. Thank you all for helping me writing this -\LaTeX\ sample file. See \ref{suppA} for the supplementary material example. - -\begin{supplement} -\sname{Supplement A}\label{suppA} -\stitle{Title of the Supplement A} -\slink[url]{http://www.e-publications.org/ims/support/dowload/imsart-ims.zip} -\sdescription{Dum esset rex in -accubitu suo, nardus mea dedit odorem suavitatis. Quoniam confortavit -seras portarum tuarum, benedixit filiis tuis in te. Qui posuit fines tuos} -\end{supplement} - - -\begin{thebibliography}{9} - -\bibitem{r1} -\textsc{Billingsley, P.} (1999). \textit{Convergence of -Probability Measures}, 2nd ed. -Wiley, New York. -\MR{1700749} - - -\bibitem{r2} -\textsc{Bourbaki, N.} (1966). \textit{General Topology} \textbf{1}. -Addison--Wesley, Reading, MA. - -\bibitem{r3} -\textsc{Ethier, S. N.} and \textsc{Kurtz, T. G.} (1985). -\textit{Markov Processes: Characterization and Convergence}. -Wiley, New York. -\MR{838085} - -\bibitem{r4} -\textsc{Prokhorov, Yu.} (1956). -Convergence of random processes and limit theorems in probability -theory. \textit{Theory Probab. Appl.} -\textbf{1} 157--214. -\MR{84896} - -\end{thebibliography} - -\end{document} +\documentclass[aoas,preprint]{imsart} + +\RequirePackage[OT1]{fontenc} +\RequirePackage{amsthm,amsmath} +\RequirePackage[numbers]{natbib} +\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref} + +% settings +%\pubyear{2005} +%\volume{0} +%\issue{0} +%\firstpage{1} +%\lastpage{8} +\arxiv{arXiv:0000.0000} + +\startlocaldefs +\numberwithin{equation}{section} +\theoremstyle{plain} +\newtheorem{thm}{Theorem}[section] +\endlocaldefs + +\begin{document} + +\begin{frontmatter} +\title{A Sample Document\thanksref{T1}} +\runtitle{A Sample Document} +\thankstext{T1}{Footnote to the title with the ``thankstext'' command.} + +\begin{aug} +\author{\fnms{First} \snm{Author}\thanksref{t1,t2,m1}\ead[label=e1]{first@somewhere.com}}, +\author{\fnms{Second} \snm{Author}\thanksref{t3,m1,m2}\ead[label=e2]{second@somewhere.com}} +\and +\author{\fnms{Third} \snm{Author}\thanksref{t1,m2} +\ead[label=e3]{third@somewhere.com} +\ead[label=u1,url]{http://www.foo.com}} + +\thankstext{t1}{Some comment} +\thankstext{t2}{First supporter of the project} +\thankstext{t3}{Second supporter of the project} +\runauthor{F. Author et al.} + +\affiliation{Some University\thanksmark{m1} and Another University\thanksmark{m2}} + +\address{Address of the First and Second authors\\ +Usually a few lines long\\ +\printead{e1}\\ +\phantom{E-mail:\ }\printead*{e2}} + +\address{Address of the Third author\\ +Usually a few lines long\\ +Usually a few lines long\\ +\printead{e3}\\ +\printead{u1}} +\end{aug} + +\begin{abstract} +The abstract should summarize the contents of the paper. +It should be clear, descriptive, self-explanatory and not longer +than 200 words. It should also be suitable for publication in +abstracting services. Please avoid using math formulas as much as possible. + +This is a sample input file. Comparing it with the output it +generates can show you how to produce a simple document of +your own. +\end{abstract} + +\begin{keyword}[class=MSC] +\kwd[Primary ]{60K35} +\kwd{60K35} +\kwd[; secondary ]{60K35} +\end{keyword} + +\begin{keyword} +\kwd{sample} +\kwd{\LaTeXe} +\end{keyword} + +\end{frontmatter} + +\section{Ordinary text} + +The ends of words and sentences are marked + by spaces. It doesn't matter how many +spaces you type; one is as good as 100. The +end of a line counts as a space. + +One or more blank lines denote the end +of a paragraph. + +Since any number of consecutive spaces are treated like a single +one, the formatting of the input file makes no difference to + \TeX, % The \TeX command generates the TeX logo. +but it makes a difference to you. +When you use + \LaTeX, % The \LaTeX command generates the LaTeX logo. +making your input file as easy to read as possible +will be a great help as you write your document and when you +change it. This sample file shows how you can add comments to +your own input file. + +Because printing is different from typewriting, there are a +number of things that you have to do differently when preparing +an input file than if you were just typing the document directly. +Quotation marks like + ``this'' +have to be handled specially, as do quotes within quotes: + ``\,`this' % \, separates the double and single quote. + is what I just + wrote, not `that.'\,'' + +Dashes come in three sizes: a hyphen, %an intra-word dash, +a medium dash for number ranges like + 1--2, +and a punctuation dash in place of a comma, semicolon, colon or parentheses + ---like +this. + +A sentence-ending space should be larger than the space between words +within a sentence. You sometimes have to type special commands in +conjunction with punctuation characters to get this right, as in the +following sentence. + Gnats, gnus, etc.\ % `\ ' makes an inter-word space. + all begin with G\@. % \@ marks end-of-sentence punctuation. +You should check the spaces after periods when reading your output to +make sure you haven't forgotten any special cases. +Generating an ellipsis + \ldots\ % `\ ' needed because TeX ignores spaces after + % command names like \ldots made from \ + letters. + % + % Note how a `%' character causes TeX to ignore the + % end of the input line, so these blank lines do not + % start a new paragraph. +with the right spacing around the periods +requires a special command. + +\TeX\ interprets some common characters as commands, so you must type +special commands to generate them. These characters include the +following: +% \$ - arXiv do not like it... + \& \% \# \{ and~\}. + +In printing, text is emphasized by using an + {\em italic\/} % The \/ command produces the tiny extra space that + % should be added between a slanted and a following + % unslanted letter. +type style. + +\begin{em} + A long segment of text can also be emphasized in this way. Text within + such a segment given additional emphasis + with\/ {\em Roman} + type. Italic type loses its ability to emphasize and become simply + distracting when used excessively. +\end{em} + +It is sometimes necessary to prevent \TeX\ from breaking a line where +it might otherwise do so. This may be at a space, as between the +``Mr.'' and ``Jones'' in + ``Mr.~Jones'', % ~ produces an unbreakable interword space. +or within a word---especially when the word is a symbol like + \mbox{\em itemnum\/} +that makes little sense when hyphenated across + lines. + +\TeX\ is good at typesetting mathematical formulas like + \( x-3y = 7 \) +or + \( a_{1} > x^{2n} / y^{2n} > x' \). +Remember that a letter like + $x$ % $ ... $ and \( ... \) are equivalent +is a formula when it denotes a mathematical symbol, and should +be treated as one. + + +\section{Notes} +Footnotes\footnote{This is an example of a footnote.} +pose no problem\footnote{And another one}. + +\section{Displayed text} + +Text is displayed by indenting it from the left margin. +Quotations are commonly displayed. There are short quotations +\begin{quote} + This is a short a quotation. It consists of a + single paragraph of text. There is no paragraph + indentation. +\end{quote} +and longer ones. +\begin{quotation} + This is a longer quotation. It consists of two paragraphs + of text. The beginning of each paragraph is indicated + by an extra indentation. + + This is the second paragraph of the quotation. It is just + as dull as the first paragraph. +\end{quotation} +Another frequently displayed structure is a list. +The following is an example of an {\em itemized} list, +four levels deep. +\begin{itemize} +\item This is the first item of an itemized list. Each item + in the list is marked with a ``tick.'' The document + style determines what kind of tick mark is used. +\item This is the second item of the list. It contains another + list nested inside it. The three inner lists are an {\em itemized} + list. + \begin{itemize} + \item This is the first item of an enumerated list that + is nested within the itemized list. + \item This is the second item of the inner list. \LaTeX\ + allows you to nest lists deeper than you really should. + \end{itemize} + This is the rest of the second item of the outer list. It + is no more interesting than any other part of the item. + \item This is the third item of the list. +\end{itemize} + + +The following is an example of an {\em enumerated} list, four levels deep. +\begin{enumerate} +\item This is the first item of an enumerated list. Each item + in the list is marked with a ``tick.'' The document + style determines what kind of tick mark is used. +\item This is the second item of the list. It contains another + list nested inside it. The three inner lists are an {\em enumerated} + list. + \begin{enumerate} + \item This is the first item of an enumerated list that + is nested within the enumerated list. + \item This is the second item of the inner list. \LaTeX\ + allows you to nest lists deeper than you really should. + \end{enumerate} + This is the rest of the second item of the outer list. It + is no more interesting than any other part of the item. + \item This is the third item of the list. +\end{enumerate} + + +The following is an example of a {\em description} list. +\begin{description} +\item[Cow] Highly intelligent animal that can produce milk out of grass. +\item[Horse] Less intelligent animal renowned for its legs. +\item[Human being] Not so intelligent animal convinced it can think. +\end{description} + +You can even display poetry. +\begin{verse} + There is an environment for verse \\ % The \\ command separates lines + Whose features some poets will curse. % within a stanza. + + % One or more blank lines separate stanzas. + + For instead of making\\ + Them do {\em all\/} line breaking, \\ + It allows them to put too many words on a line when they'd + rather be forced to be terse. +\end{verse} + +Mathematical formulas may also be displayed. A displayed formula is +one-line long: + + \[ x' + y^{2} = z_{i}^{2};\] + +multiline formulas require special formatting +instructions. + +Don't start a paragraph with a displayed equation, nor make +one a paragraph by itself. + +Example of a theorem: + + +\begin{thm} +All conjectures are interesting, but some conjectures are more +interesting than others. +\end{thm} + +\begin{proof} +Obvious. +\end{proof} + +\section{Tables and figures} +Cross reference to labeled table: As you can see in Table~\ref{sphericcase} on +page~\pageref{sphericcase} and also in Table~\ref{parset} on page~\pageref{parset}. + + +\begin{table*} +\caption{The spherical case ($I_1=0$, $I_2=0$)} +\label{sphericcase} +\begin{tabular}{crrrrc} +\hline +Equil. \\ +Points & \multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$y$} & \multicolumn{1}{c}{$z$} & \multicolumn{1}{c}{$C$} & +S \\ +\hline +$~~L_1$ & $-$2.485252241 & 0.000000000 & 0.017100631 & 8.230711648 & U \\ +$~~L_2$ & 0.000000000 & 0.000000000 & 3.068883732 & 0.000000000 & S \\ +$~~L_3$ & 0.009869059 & 0.000000000 & 4.756386544 & $-$0.000057922 & U \\ +$~~L_4$ & 0.210589855 & 0.000000000 & $-$0.007021459 & 9.440510897 & U \\ +$~~L_5$ & 0.455926604 & 0.000000000 & $-$0.212446624 & 7.586126667 & U \\ +$~~L_6$ & 0.667031314 & 0.000000000 & 0.529879957 & 3.497660052 & U \\ +$~~L_7$ & 2.164386674 & 0.000000000 & $-$0.169308438 & 6.866562449 & U \\ +$~~L_8$ & 0.560414471 & 0.421735658 & $-$0.093667445 & 9.241525367 & U \\ +$~~L_9$ & 0.560414471 & $-$0.421735658 & $-$0.093667445 & 9.241525367 & U +\\ +$~~L_{10}$ & 1.472523232 & 1.393484549 & $-$0.083801333 & 6.733436505 & U \\ +$~~L_{11}$ & 1.472523232 & $-$1.393484549 & $-$0.083801333 & 6.733436505 & U +\\ \hline +\end{tabular} +\end{table*} + + +A major +point of difference lies in the value of the specific production rate $\pi$ for +large values of the specific growth rate $\mu$. +Already in the early publications \cite{r1,r2,r3} +it appeared that high glucose +concentrations in the production phase are well correlated with a +low penicillin yield (the +``glucose effect''). It has been confirmed recently +\cite{r1,r2,r3,r4} +that +high glucose concentrations inhibit the synthesis of the enzymes of the +penicillin pathway, but not the actual penicillin biosynthesis. +In other words, glucose represses (and not inhibits) the penicillin +biosynthesis. + +These findings do not contradict the results of +\cite{r1} and of \cite{r4} which were obtained for +continuous culture fermentations. +Because for high values of the specific +growth rate $\mu$ it is most likely (as shall be discussed below) that +maintenance metabolism occurs, it can be shown that +in steady state continuous culture conditions, and with $\mu$ described by a Monod kinetics +\begin{equation} + C_{s} = K_{M} \frac{\mu/\mu_{x}}{1-\mu/\mu_{x}} \label{cs} +\end{equation} +Pirt \& Rhigelato determined $\pi$ for $\mu$ between +$0.023$ and $0.086$ h$^{-1}$. +They also reported a value $\mu_{x} \approx 0.095$ +h$^{-1}$, so that for their experiments $\mu/\mu_{x}$ is in the range +of $0.24$ to $0.9$. +Substituting $K _M$ in equation (\ref{cs}) by +the value $K_{M}=1$ g/L as used by \cite{r1}, one finds +with the above equation $0.3 < C_{s} < 9$ g/L. This agrees with +the work of \cite{r4}, who reported that penicillin biosynthesis +repression only occurs at glucose concentrations from $C_{s}=10$ g/L on. +The conclusion is that the glucose concentrations in the experiments of +Pirt \& Rhigelato probably were too low for glucose repression to be +detected. The experimental data published by Ryu \& Hospodka +are not detailed sufficiently to permit a similar analysis. + +\begin{table} +\centering +\caption{Parameter sets used by Bajpai \& Reu\ss\ }\label{parset} +\begin{tabular}{lrll} +\hline +\multicolumn{2}{l}{\it parameter} & {\it Set 1} & {\it Set 2}\\ +\hline +$\mu_{x}$ & [h$^{-1}$] & 0.092 & 0.11 \\ +$K_{x}$ & [g/g DM] & 0.15 & 0.006 \\ +$\mu_{p}$ & [g/g DM h] & 0.005 & 0.004 \\ +$K_{p}$ & [g/L] & 0.0002 & 0.0001 \\ +$K_{i}$ & [g/L] & 0.1 & 0.1 \\ +$Y_{x/s}$ & [g DM/g] & 0.45 & 0.47 \\ +$Y_{p/s}$ & [g/g] & 0.9 & 1.2 \\ +$k_{h}$ & [h$^{-1}$] & 0.04 & 0.01 \\ +$m_{s}$ & [g/g DM h] & 0.014 & 0.029 \\ +\hline +\end{tabular} +\end{table} + +Bajpai \& Reu\ss\ decided to disregard the +differences between time constants for the two regulation mechanisms +(glucose repression or inhibition) because of the +relatively very long fermentation times, and therefore proposed a Haldane +expression for $\pi$. + +It is interesting that simulations with the \cite{r4} model for the +initial conditions given by these authors indicate that, when the +remaining substrate is fed at a constant rate, a considerable and +unrealistic amount of penicillin is +produced when the glucose concentration is still very high \cite{r2,r3,r4} +Simulations with the Bajpai \& Reu\ss\ model correctly predict almost +no penicillin production in similar conditions. + +\begin{figure} % figuur 1 +\vspace{6pc} +\caption[]{Pathway of the penicillin G biosynthesis.} +\label{penG} +\end{figure} + +Sample of cross-reference to figure. +Figure~\ref{penG} shows that is not easy to get something on paper. + + + +\section{Headings} + +\subsection{Subsection} +Carr--Goldstein based their model on balancing methods and +biochemical know\-ledge. The original model (1980) contained an equation for the +oxygen dynamics which has been omitted in a second paper +(1981). This simplified model shall be discussed here. + +\subsubsection{Subsubsection} +Carr--Goldstein +based their model on balancing methods and +biochemical know\-ledge. The original model (1980) contained an equation for the +oxygen dynamics which has been omitted in a second paper +(1981). This simplified model shall be discussed here. + +\section{Equations and the like} + +Two equations: +\begin{equation} + C_{s} = K_{M} \frac{\mu/\mu_{x}}{1-\mu/\mu_{x}} \label{ccs} +\end{equation} +and +\begin{equation} + G = \frac{P_{\rm opt} - P_{\rm ref}}{P_{\rm ref}} \mbox{\ }100 \mbox{\ }(\%). +\end{equation} + +Two equation arrays: + +\begin{eqnarray} + \frac{dS}{dt} & = & - \sigma X + s_{F} F\\ + \frac{dX}{dt} & = & \mu X\\ + \frac{dP}{dt} & = & \pi X - k_{h} P\\ + \frac{dV}{dt} & = & F +\end{eqnarray} +and +\begin{eqnarray} + \mu_{\rm substr} & = & \mu_{x} \frac{C_{s}}{K_{x}C_{x}+C_{s}} \\ + \mu & = & \mu_{\rm substr} - Y_{x/s}(1-H(C_{s}))(m_{s}+\pi /Y_{p/s}) \\ + \sigma & = & \mu_{\rm substr}/Y_{x/s}+ H(C_{s}) (m_{s}+ \pi /Y_{p/s}). +\end{eqnarray} + + +\appendix + +\section{Appendix section}\label{app} + +We consider a sequence of queueing systems +indexed by $n$. It is assumed that each system +is composed of $J$ stations, indexed by $1$ +through $J$, and $K$ customer classes, indexed +by $1$ through $K$. Each customer class +has a fixed route through the network of +stations. Customers in class +$k$, $k=1,\ldots,K$, arrive to the +system according to a +renewal process, independently of the arrivals +of the other customer classes. These customers +move through the network, never visiting a station +more than once, until they eventually exit +the system. + +\subsection{Appendix subsection} + +However, different customer classes may visit +stations in different orders; the system +is not necessarily ``feed-forward.'' +We define the {\em path of class $k$ customers} in +as the sequence of servers +they encounter along their way through the network +and denote it by +\begin{equation} +\mathcal{P}=\bigl(j_{k,1},j_{k,2},\dots,j_{k,m(k)}\bigr). \label{path} +\end{equation} + +Sample of cross-reference to the formula \ref{path} in Appendix \ref{app}. + +\section*{Acknowledgements} +And this is an acknowledgements section with a heading that was produced by the +$\backslash$section* command. Thank you all for helping me writing this +\LaTeX\ sample file. See \ref{suppA} for the supplementary material example. + +\begin{supplement} +\sname{Supplement A}\label{suppA} +\stitle{Title of the Supplement A} +\slink[url]{http://www.e-publications.org/ims/support/dowload/imsart-ims.zip} +\sdescription{Dum esset rex in +accubitu suo, nardus mea dedit odorem suavitatis. Quoniam confortavit +seras portarum tuarum, benedixit filiis tuis in te. Qui posuit fines tuos} +\end{supplement} + + +\begin{thebibliography}{9} + +\bibitem{r1} +\textsc{Billingsley, P.} (1999). \textit{Convergence of +Probability Measures}, 2nd ed. +Wiley, New York. +\MR{1700749} + + +\bibitem{r2} +\textsc{Bourbaki, N.} (1966). \textit{General Topology} \textbf{1}. +Addison--Wesley, Reading, MA. + +\bibitem{r3} +\textsc{Ethier, S. N.} and \textsc{Kurtz, T. G.} (1985). +\textit{Markov Processes: Characterization and Convergence}. +Wiley, New York. +\MR{838085} + +\bibitem{r4} +\textsc{Prokhorov, Yu.} (1956). +Convergence of random processes and limit theorems in probability +theory. \textit{Theory Probab. Appl.} +\textbf{1} 157--214. +\MR{84896} + +\end{thebibliography} + +\end{document} diff --git a/manuscript/aoas/ims-template.tex b/manuscript/tempopaper/aoas/ims-template.tex old mode 100755 new mode 100644 similarity index 96% rename from manuscript/aoas/ims-template.tex rename to manuscript/tempopaper/aoas/ims-template.tex index 6d6a1dc..f58eea8 --- a/manuscript/aoas/ims-template.tex +++ b/manuscript/tempopaper/aoas/ims-template.tex @@ -1,80 +1,80 @@ -% Template for the submission to: -% The Annals of Probability [aop] -% The Annals of Applied Probability [aap] -% The Annals of Statistics [aos] -% The Annals of Applied Statistics [aoas] -% Stochastic Systems [ssy] -% -%Author: In this template, the places where you need to add information -% (or delete line) are indicated by {???}. Mostly the information -% required is obvious, but some explanations are given in lines starting -%Author: -%All other lines should be ignored. After editing, there should be -%no instances of ??? after this line. - -% use option [preprint] to remove info line at bottom -% journal options: aop,aap,aos,aoas,ssy -% natbib option: authoryear -\documentclass[???]{imsart} - -%\usepackage{amsthm,amsmath,natbib} -%\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref} - -% provide arXiv number if available: -%\arxiv{arXiv:0000.0000} - -% put your definitions there: -\startlocaldefs -\endlocaldefs - -\begin{document} - -\begin{frontmatter} - -% "Title of the paper" -\title{???} -\runtitle{???} - -% indicate corresponding author with \corref{} -% \author{\fnms{John} \snm{Smith}\corref{}\ead[label=e1]{smith@foo.com}\thanksref{t1}} -% \thankstext{t1}{Thanks to somebody} -% \address{line 1\\ line 2\\ printead{e1}} -% \affiliation{Some University} - -\author{\fnms{???} \snm{???}\ead[label=e1]{???}} -\address{\printead{e1}} -%\and -%\author{\fnms{???} \snm{???}\ead[label=e2]{???}} -%\address{\printead{e2}} -%\affiliation{???} - -\runauthor{???} - -%\begin{abstract} -%\end{abstract} - -%\begin{keyword}[class=MSC] -%\kwd[Primary ]{} -%\kwd{} -%\kwd[; secondary ]{} -%\end{keyword} - -%\begin{keyword} -%\kwd{} -%\kwd{} -%\end{keyword} - -\end{frontmatter} - - -% AOS,AOAS: If there are supplements please fill: -%\begin{supplement}[id=suppA] -% \sname{Supplement A} -% \stitle{Title} -% \slink[doi]{10.1214/00-AOASXXXXSUPP} -% \sdatatype{.pdf}" -% \sdescription{Some text} -%\end{supplement} - - -\end{document} +% Template for the submission to: +% The Annals of Probability [aop] +% The Annals of Applied Probability [aap] +% The Annals of Statistics [aos] +% The Annals of Applied Statistics [aoas] +% Stochastic Systems [ssy] +% +%Author: In this template, the places where you need to add information +% (or delete line) are indicated by {???}. Mostly the information +% required is obvious, but some explanations are given in lines starting +%Author: +%All other lines should be ignored. After editing, there should be +%no instances of ??? after this line. + +% use option [preprint] to remove info line at bottom +% journal options: aop,aap,aos,aoas,ssy +% natbib option: authoryear +\documentclass[???]{imsart} + +%\usepackage{amsthm,amsmath,natbib} +%\RequirePackage[colorlinks,citecolor=blue,urlcolor=blue]{hyperref} + +% provide arXiv number if available: +%\arxiv{arXiv:0000.0000} + +% put your definitions there: +\startlocaldefs +\endlocaldefs + +\begin{document} + +\begin{frontmatter} + +% "Title of the paper" +\title{???} +\runtitle{???} + +% indicate corresponding author with \corref{} +% \author{\fnms{John} \snm{Smith}\corref{}\ead[label=e1]{smith@foo.com}\thanksref{t1}} +% \thankstext{t1}{Thanks to somebody} +% \address{line 1\\ line 2\\ printead{e1}} +% \affiliation{Some University} + +\author{\fnms{???} \snm{???}\ead[label=e1]{???}} +\address{\printead{e1}} +%\and +%\author{\fnms{???} \snm{???}\ead[label=e2]{???}} +%\address{\printead{e2}} +%\affiliation{???} + +\runauthor{???} + +%\begin{abstract} +%\end{abstract} + +%\begin{keyword}[class=MSC] +%\kwd[Primary ]{} +%\kwd{} +%\kwd[; secondary ]{} +%\end{keyword} + +%\begin{keyword} +%\kwd{} +%\kwd{} +%\end{keyword} + +\end{frontmatter} + + +% AOS,AOAS: If there are supplements please fill: +%\begin{supplement}[id=suppA] +% \sname{Supplement A} +% \stitle{Title} +% \slink[doi]{10.1214/00-AOASXXXXSUPP} +% \sdatatype{.pdf}" +% \sdescription{Some text} +%\end{supplement} + + +\end{document} diff --git a/manuscript/aoas/imsart-nameyear.bst b/manuscript/tempopaper/aoas/imsart-nameyear.bst old mode 100755 new mode 100644 similarity index 100% rename from manuscript/aoas/imsart-nameyear.bst rename to manuscript/tempopaper/aoas/imsart-nameyear.bst diff --git a/manuscript/aoas/imsart.cls b/manuscript/tempopaper/aoas/imsart.cls old mode 100755 new mode 100644 similarity index 96% rename from manuscript/aoas/imsart.cls rename to manuscript/tempopaper/aoas/imsart.cls index 7367655..b9a251a --- a/manuscript/aoas/imsart.cls +++ b/manuscript/tempopaper/aoas/imsart.cls @@ -1,183 +1,183 @@ -%% This is file `imsart.cls' -%% -%% LaTeX 2e class file for the processing of LaTeX2e files -%% of the following IMS/BS journals: -%% -%% The Annals of Probability -%% The Annals of Applied Probability -%% The Annals of Statistics -%% The Annals of Applied Statistics -%% Statistical Science -%% Probability Surveys -%% Statistics Surveys -%% Electronic Journal of Statistics -%% IMS Lecture Notes-Monograph Series -%% IMS Collections -%% Bernoulli -%% Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques -%% Brazilian Journal of Probability and Statistics -%% Stochastic Systems -%% -%% Institute of Mathematical Statistics, U.S.A. -%% Bernoulli Society -%% Institut Henry Poincare -%% Brazilian Statistical Association -%% -%% Macros written by Vytas Statulevicius, VTeX, Lithuania -%% for Institute of Mathematical Statistics, U.S.A. -%% Please submit bugs or your comments to vytas@vtex.lt -%% -%% The original distribution is located at: -%% http://www.e-publications.org/ims/support -%% -%% This class file loads standart "article.cls" with appropriate -%% settings and then style file "imsart.sty" with additional macros -%% -%% You are free to use this style file as you see fit, provided -%% that you do not make changes to the file. -%% If you DO make changes, you are required to rename this file. -%% -%% It may be distributed under the terms of the LaTeX Project Public -%% License, as described in lppl.txt in the base LaTeX distribution. -%% Either version 1.0 or, at your option, any later version. -%% -%% \CharacterTable -%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -%% Digits \0\1\2\3\4\5\6\7\8\9 -%% Exclamation \! Double quote \" Hash (number) \# -%% Dollar \$ Percent \% Ampersand \& -%% Acute accent \' Left paren \( Right paren \) -%% Asterisk \* Plus \+ Comma \, -%% Minus \- Point \. Solidus \/ -%% Colon \: Semicolon \; Less than \< -%% Equals \= Greater than \> Question mark \? -%% Commercial at \@ Left bracket \[ Backslash \\ -%% Right bracket \] Circumflex \^ Underscore \_ -%% Grave accent \` Left brace \{ Vertical bar \| -%% Right brace \} Tilde \~} -%% -%% -%% Bug fixes and changes: at end of file - -% TeX programming: Vytas Statulevicius, VTeX, Lithuania, vytas@vtex.lt -% Requires Latex2e, ver.2000.06 - - -\NeedsTeXFormat{LaTeX2e} -\ProvidesClass{imsart}[2010/04/27 driver class for package imsart.sty] - -% layout options: - -\DeclareOption{imslayout}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath}} - -\DeclareOption{stslayout}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath}} - - -% set various options for different journals: -\DeclareOption{generic}{% - \PassOptionsToClass{10pt,oneside}{article} -} - - -\DeclareOption{ps}{% - \PassOptionsToClass{10pt,oneside}{article} -} - -\DeclareOption{ss}{% - \PassOptionsToClass{10pt,oneside}{article} -} - -\DeclareOption{ejs}{% - \PassOptionsToClass{10pt,oneside}{article} -} - -\DeclareOption{lnms}{ - \PassOptionsToClass{10pt,twoside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - -\DeclareOption{coll}{ - \PassOptionsToClass{10pt,twoside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - - -\DeclareOption{aap}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - -\DeclareOption{aop}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - -\DeclareOption{aos}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - -\DeclareOption{aoas}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - - -\DeclareOption{sts}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - -\DeclareOption{bj}{% - \PassOptionsToClass{10pt,oneside}{article} -} - -\DeclareOption{aihp}{% - \PassOptionsToClass{10pt,oneside,fleqn}{article} - \PassOptionsToPackage{fleqn}{amsmath} - \PassOptionsToPackage{numbers,sort&compress}{natbib} -} - - -\DeclareOption{bjps}{ - \PassOptionsToClass{11pt,twoside}{article} -} - -\DeclareOption{ssy}{% - \PassOptionsToClass{11pt,oneside,leqno}{article} - \PassOptionsToPackage{leqno}{amsmath} -} - - -\PassOptionsToPackage{psamsfonts}{amssymb} -\PassOptionsToPackage{cmex10}{amsmath} - -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} -\ProcessOptions* - -\LoadClass{article} - -\IfFileExists{imsart.sty}{}{\ClassError{imsart}{The complimentary style file "imsart.sty" is required}{ -The complimentary style file "imsart.sty" is required\MessageBreak -You need to install file "imsart.sty" in your system\MessageBreak -File could be downloaded from http://www.e-publications.org/ims/support -}} - -% Load additional macros and modifications for "article.cls" -\RequirePackage[generic]{imsart} - -\endinput -%% -%% History: -%% 2010.04.27 - support for the "Stochastic Systems" (ssy) added; -%% 2009.08.13 - options [numbers,sort&compress] from natbib package removed -%% 2009.05.21 - added new option "bjps" -%% 2008.01.09 - added new option "coll" -%% 2007.12.10 - added new option "aihp" -%% 2007.08.22 - aoas: default value for natbib set to authoryear -%% End of file `imsart.cls'. +%% This is file `imsart.cls' +%% +%% LaTeX 2e class file for the processing of LaTeX2e files +%% of the following IMS/BS journals: +%% +%% The Annals of Probability +%% The Annals of Applied Probability +%% The Annals of Statistics +%% The Annals of Applied Statistics +%% Statistical Science +%% Probability Surveys +%% Statistics Surveys +%% Electronic Journal of Statistics +%% IMS Lecture Notes-Monograph Series +%% IMS Collections +%% Bernoulli +%% Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques +%% Brazilian Journal of Probability and Statistics +%% Stochastic Systems +%% +%% Institute of Mathematical Statistics, U.S.A. +%% Bernoulli Society +%% Institut Henry Poincare +%% Brazilian Statistical Association +%% +%% Macros written by Vytas Statulevicius, VTeX, Lithuania +%% for Institute of Mathematical Statistics, U.S.A. +%% Please submit bugs or your comments to vytas@vtex.lt +%% +%% The original distribution is located at: +%% http://www.e-publications.org/ims/support +%% +%% This class file loads standart "article.cls" with appropriate +%% settings and then style file "imsart.sty" with additional macros +%% +%% You are free to use this style file as you see fit, provided +%% that you do not make changes to the file. +%% If you DO make changes, you are required to rename this file. +%% +%% It may be distributed under the terms of the LaTeX Project Public +%% License, as described in lppl.txt in the base LaTeX distribution. +%% Either version 1.0 or, at your option, any later version. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +%% +%% Bug fixes and changes: at end of file + +% TeX programming: Vytas Statulevicius, VTeX, Lithuania, vytas@vtex.lt +% Requires Latex2e, ver.2000.06 + + +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{imsart}[2010/04/27 driver class for package imsart.sty] + +% layout options: + +\DeclareOption{imslayout}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath}} + +\DeclareOption{stslayout}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath}} + + +% set various options for different journals: +\DeclareOption{generic}{% + \PassOptionsToClass{10pt,oneside}{article} +} + + +\DeclareOption{ps}{% + \PassOptionsToClass{10pt,oneside}{article} +} + +\DeclareOption{ss}{% + \PassOptionsToClass{10pt,oneside}{article} +} + +\DeclareOption{ejs}{% + \PassOptionsToClass{10pt,oneside}{article} +} + +\DeclareOption{lnms}{ + \PassOptionsToClass{10pt,twoside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + +\DeclareOption{coll}{ + \PassOptionsToClass{10pt,twoside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + + +\DeclareOption{aap}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + +\DeclareOption{aop}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + +\DeclareOption{aos}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + +\DeclareOption{aoas}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + + +\DeclareOption{sts}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + +\DeclareOption{bj}{% + \PassOptionsToClass{10pt,oneside}{article} +} + +\DeclareOption{aihp}{% + \PassOptionsToClass{10pt,oneside,fleqn}{article} + \PassOptionsToPackage{fleqn}{amsmath} + \PassOptionsToPackage{numbers,sort&compress}{natbib} +} + + +\DeclareOption{bjps}{ + \PassOptionsToClass{11pt,twoside}{article} +} + +\DeclareOption{ssy}{% + \PassOptionsToClass{11pt,oneside,leqno}{article} + \PassOptionsToPackage{leqno}{amsmath} +} + + +\PassOptionsToPackage{psamsfonts}{amssymb} +\PassOptionsToPackage{cmex10}{amsmath} + +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} +\ProcessOptions* + +\LoadClass{article} + +\IfFileExists{imsart.sty}{}{\ClassError{imsart}{The complimentary style file "imsart.sty" is required}{ +The complimentary style file "imsart.sty" is required\MessageBreak +You need to install file "imsart.sty" in your system\MessageBreak +File could be downloaded from http://www.e-publications.org/ims/support +}} + +% Load additional macros and modifications for "article.cls" +\RequirePackage[generic]{imsart} + +\endinput +%% +%% History: +%% 2010.04.27 - support for the "Stochastic Systems" (ssy) added; +%% 2009.08.13 - options [numbers,sort&compress] from natbib package removed +%% 2009.05.21 - added new option "bjps" +%% 2008.01.09 - added new option "coll" +%% 2007.12.10 - added new option "aihp" +%% 2007.08.22 - aoas: default value for natbib set to authoryear +%% End of file `imsart.cls'. diff --git a/manuscript/aoas/imsart.sty b/manuscript/tempopaper/aoas/imsart.sty old mode 100755 new mode 100644 similarity index 96% rename from manuscript/aoas/imsart.sty rename to manuscript/tempopaper/aoas/imsart.sty index 48279d2..2457a09 --- a/manuscript/aoas/imsart.sty +++ b/manuscript/tempopaper/aoas/imsart.sty @@ -1,3120 +1,3120 @@ -%% This is file `imsart.sty' -%% -%% LaTeX 2e style file for the processing of LaTeX2e files -%% of the following IMS/BS journals: -%% -%% The Annals of Probability -%% The Annals of Applied Probability -%% The Annals of Statistics -%% The Annals of Applied Statistics -%% Statistical Science -%% Probability Surveys -%% Statistics Surveys -%% Electronic Journal of Statistics -%% IMS Lecture Notes-Monograph Series -%% IMS Collections -%% Bernoulli -%% Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques -%% Brazilian Journal of Probability and Statistics -%% Stochastic Systems -%% -%% Institute of Mathematical Statistics, U.S.A. -%% Bernoulli Society -%% Institut Henry Poincare -%% Brazilian Statistical Association -%% -%% Macros written by Vytas Statulevicius, VTeX, Lithuania -%% for Institute of Mathematical Statistics, U.S.A. -%% Please submit bugs or your comments to vytas@vtex.lt -%% -%% The original distribution is located at: -%% http://www.e-publications.org/ims/support -%% -%% This style file contains additional macros and is designed to use -%% with standart "article.cls" -%% -%% You are free to use this style file as you see fit, provided -%% that you do not make changes to the file. -%% If you DO make changes, you are required to rename this file. -%% -%% It may be distributed under the terms of the LaTeX Project Public -%% License, as described in lppl.txt in the base LaTeX distribution. -%% Either version 1.0 or, at your option, any later version. -%% -%% \CharacterTable -%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z -%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -%% Digits \0\1\2\3\4\5\6\7\8\9 -%% Exclamation \! Double quote \" Hash (number) \# -%% Dollar \$ Percent \% Ampersand \& -%% Acute accent \' Left paren \( Right paren \) -%% Asterisk \* Plus \+ Comma \, -%% Minus \- Point \. Solidus \/ -%% Colon \: Semicolon \; Less than \< -%% Equals \= Greater than \> Question mark \? -%% Commercial at \@ Left bracket \[ Backslash \\ -%% Right bracket \] Circumflex \^ Underscore \_ -%% Grave accent \` Left brace \{ Vertical bar \| -%% Right brace \} Tilde \~} -%% -%% -%% Bug fixes and changes: at end of file - -% TeX programming: Vytas Statulevicius, VTeX, Lithuania, vytas@vtex.lt -% Requires Latex2e, ver.2000.06 - -\def\imsfmt@name{imsart} -\def\imsfmt@version{2014/10/16} - -\ProvidesFile{imsart.sty} - [\imsfmt@version IMS article style (VS)] - -% hyperref must be loaded after: -\@ifpackageloaded{hyperref}{\@latex@error{Package 'hyperref' must be loaded after 'imsart'!}\@ehc}{} - -% Passoptions to hyperref: - -\PassOptionsToPackage{colorlinks,citecolor=blue,urlcolor=blue,linkcolor=blue,pagecolor=blue,linktocpage=true}{hyperref} - -% General options: - -% Put keywords as footnote -\newif\if@keywordsasfootnote -\DeclareOption{keywordsasfootnote}{\@keywordsasfootnotetrue} - -% Put history as footnote -\newif\if@historyasfootnote -\DeclareOption{historyasfootnote}{\@historyasfootnotetrue} - -% Put address as footnote -\newif\if@addressasfootnote -\DeclareOption{addressasfootnote}{\@addressasfootnotetrue} - -% Put addresses at end of document -\newif\if@addressatend -\DeclareOption{addressatend}{\@addressatendtrue} - -% Put "." after inline section headings: -\newif\if@autosecdot -\DeclareOption{autosecdot} {\@autosecdottrue} -\DeclareOption{noautosecdot}{\AtBeginDocument{\@autosecdotfalse}} - -% do not print thanksref undefined marks -\newif\if@noundefthanksref -\DeclareOption{noundefthanksref}{\@noundefthanksreftrue} - -% Load amsmath style with corerect settings: -\newif\if@load@amsmath -\DeclareOption{amsmath}{\@load@amsmathtrue} - -% Load amsthm style with corerect settings: -\newif\if@load@amsthm -\DeclareOption{amsthm}{\@load@amsthmtrue} - -% Load amsmath with leqno option -\newif\if@amsmath@leqno - -% Load natbib with correct settings: -\newif\if@load@natbib -\DeclareOption{natbib}{\@load@natbibtrue} - -% When hyperref is loaded, makes a hyperlink only from year component of the cite command: -\newif\if@linksfromyear\@linksfromyearfalse -\DeclareOption{linksfromyear}{\@linksfromyeartrue} - -% For LNMS we need to create a TOC of book, so we will -% enable writing to .aux - -\newif\if@supertoc \@supertocfalse - -% Information about journals - -\def\set@generic{\def\@tempa{-generic}\ifx\journal@id\@tempa\let\affiliation\@gobble\fi} - -\DeclareOption{generic}{% - \AtEndOfPackage{\set@generic} - \def\journal@id{-generic}} - -\DeclareOption{ps}{% - \def\journal@id{-ps} - \def\journal@name{Probability Surveys } - \def\journal@issn{ISSN: 1549-5787} - \def\journal@url{http://www.i-journals.org/ps} - \AtEndOfPackage{\let\affiliation\@gobble}} - -% Information about journals -\DeclareOption{ss}{% - \def\journal@id{-ss} - \def\journal@name{Statistics Surveys } - \def\journal@issn{ISSN: 1935-7516} - \def\journal@url{http://projecteuclid.org/ssu} - \AtEndOfPackage{\let\affiliation\@gobble}} - -% Information about journals -\DeclareOption{ejs}{% - \def\journal@id{-ejs} - \def\journal@name{Electronic Journal of Statistics } - \def\journal@issn{ISSN: 1935-7524} - \def\journal@url{http://projecteuclid.org/ejs} - \AtEndOfPackage{\let\affiliation\@gobble}} - -\DeclareOption{lnms}{% - \def\journal@id{-lnms} - \def\journal@name{IMS Lecture Notes--Monograph Series } - \@twosidetrue - \def\copyrightowner@text{Institute of Mathematical Statistics} - \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% - \def\journal@url{http://www.imstat.org/publications/lecnotes.htm} - \set@page@layout{30pc}{610pt}% 30pc * 51 line - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressasfootnotetrue - \@supertoctrue - \AtBeginDocument{% - \setattribute{title} {skip} {28\p@} - \setattribute{keywordname}{size}{\itshape} - } -} - -\DeclareOption{coll}{% - \def\journal@id{-coll} - \def\journal@name{IMS Collections } - \@twosidetrue - \def\copyrightowner@text{Institute of Mathematical Statistics} - \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% - \def\journal@url{http://www.imstat.org/publications/imscollections.htm} - \set@page@layout{30pc}{610pt}% 30pc * 51 line - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressasfootnotetrue - \@supertoctrue - \AtBeginDocument{% - \setattribute{title} {skip} {28\p@} - \setattribute{keywordname}{size}{\itshape} - } -} - - -% Options for the IMS journals: - -\DeclareOption{aap}{% - \def\journal@id{-aap} - \def\journal@name{Submitted to the Annals of Applied Probability } - \def\journal@url{http://www.imstat.org/aap/} - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue -} - -\DeclareOption{aop}{% - \def\journal@id{-aop} - \def\journal@name{Submitted to the Annals of Probability } - \def\journal@url{http://www.imstat.org/aop/} - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue -} - -\DeclareOption{aos}{% - \def\journal@id{-aos} - \def\journal@name{Submitted to the Annals of Statistics } - \def\journal@url{http://www.imstat.org/aos/} - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue -} - -\DeclareOption{aoas}{% - \def\journal@id{-aoas} - \def\journal@name{Submitted to the Annals of Applied Statistics } - \def\journal@url{http://www.imstat.org/aoas/} - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue -} - - -\DeclareOption{sts}{% - \def\journal@id{-sts} - \def\journal@name{Submitted to Statistical Science } - \def\journal@url{http://www.imstat.org/sts/} - \set@page@layout{32pc}{658pt}% 32pc * 55 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@stslayouttrue - \AtBeginDocument{\if@twocolumn\set@page@layout{42pc}{658pt}\fi} -} - -\DeclareOption{bj}{% - \def\journal@id{-bj} - \def\journal@name{Submitted to Bernoulli} - \def\journal@url{http://isi.cbs.nl/bernoulli/} - \set@page@layout{32pc}{526pt}% 32pc * 44 line - \@twosidetrue - \@bjlayouttrue - \AtEndOfPackage{\let\affiliation\@gobble} -} - -\DeclareOption{aihp}{% - \def\journal@id{-aihp} - \def\journal@name{Submitted to the Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques} - \def\journal@url{http://www.imstat.org/aihp} - \set@page@layout{39pc}{622pt}% 39pc * 52 line - \@twosidetrue - \@aihplayouttrue - \AtEndOfPackage{\let\affiliation\@gobble} -} - -\DeclareOption{bjps}{% - \def\journal@id{-bjps} - \def\journal@name{Submitted to the Brazilian Journal of Probability and Statistics} - \def\journal@url{http://www.redeabe.org.br} - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@bjpslayouttrue -} - - -\DeclareOption{ssy}{% - \def\journal@id{-ssy} - \def\journal@name{Stochastic Systems } - \def\journal@url{http://www.i-journals.org/ssy/} - \def\copyrightowner@text{Institute of Mathematical Statistics} - \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% - \set@page@layout{30pc}{550pt}% 30pc * 46 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue - \@noundefthanksreftrue - \AtEndOfPackage{% - \setattribute{copyright}{text}{% - \url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% - \@ifnonempty{\@pubyear\ \@volume\@issue\@pagerange\break}% - \doi@text\break% - }} - \AtBeginDocument{\def\thebibliography{\let\section\specialsection\old@thebibliography}}% -} - -%% Layouts: -% IMS journals AAP, AOP, AOS has a different layout: - -\newif\if@imslayout \@imslayoutfalse - -\DeclareOption{imslayout}{ - \def\journal@id{-imsgeneric} - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@historyasfootnotetrue - \@keywordsasfootnotetrue - \@addressatendtrue - \@imslayouttrue - \@autosecdottrue} - -% IMS STS journal layout also specific -\newif\if@stslayout \@stslayoutfalse -\DeclareOption{stslayout}{ - \def\journal@id{-stsgeneric} - \set@page@layout{32pc}{658pt}% 32pc * 55 line - \@twosidetrue - \input{leqno.clo}% formula numbers at left - \@amsmath@leqnotrue - \@stslayouttrue - \AtBeginDocument{\if@twocolumn\set@page@layout{42pc}{658pt}\fi}} - -% BS BJ journal layout also specific: -\newif\if@bjlayout \@bjlayoutfalse - -% AIHP journal layout also specific: -\newif\if@aihplayout \@aihplayoutfalse - -% BJPS journal layout also specific: -\newif\if@bjpslayout \@bjpslayoutfalse - -% Spacing -\DeclareOption{doublespacing}{\doublespacing} -\DeclareOption{singlespacing}{\singlespacing} - -\def\singlespacing{\renewcommand{\baselinestretch}{}\large\normalsize} -\def\doublespacing{\renewcommand{\baselinestretch}{1.6}\large\normalsize} - -% Do not print id line at bottom of the page: -\DeclareOption{noinfoline}{\AtBeginDocument{\let\info@line\@empty}} -\DeclareOption{infoline} {\AtBeginDocument{\let\info@line\infoline@text}} - -% Put lines numbers in margins -\newif\ifnumberlines@ \numberlines@false -\DeclareOption{linenumbers}{\numberlines@true} -\DeclareOption{nolinenumbers}{\numberlines@false} - -% Combined options: - -% Use this option for submission for pier review: -\DeclareOption{submission}{% - \singlespacing - \AtBeginDocument{\let\info@line\infoline@text} - \numberlines@false} - -% use this option for pre-publication (preprint): - -\DeclareOption{preprint}{% - \singlespacing - \AtBeginDocument{\let\info@line\@empty} - \numberlines@false} - - - -% Initiate some info: -\def\journal@name{} -\def\journal@url{} -\def\journal@issn{} -\def\journal@id{} -\def\paper@url{} -\def\info@line{} -\def\copyrightowner@text{} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set@page@layout - -% \set@page@layout{\textwidth}{\textheight} - -\def\set@page@layout#1#2{% -% - \setlength\textwidth{#1} - \@settopoint\textwidth - \setlength\textheight{#2} - \@settopoint\textheight -% -% make side margins equal: - \setlength\@tempdima {\paperwidth} - \addtolength\@tempdima {-\textwidth} - \setlength\oddsidemargin {.5\@tempdima} - \addtolength\oddsidemargin {-1in} - \setlength\evensidemargin {\oddsidemargin} - \@settopoint\oddsidemargin - \@settopoint\evensidemargin -% -% topmargin - \setlength\topmargin{\paperheight} - \addtolength\topmargin{-2in} - \addtolength\topmargin{-\headheight} - \addtolength\topmargin{-\headsep} - \addtolength\topmargin{-\textheight} - \addtolength\topmargin{-\footskip} % this might be wrong! - \addtolength\topmargin{-.5\topmargin} - \@settopoint\topmargin -} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Load imsart.cnf with additional options: -\@input{\imsfmt@name.cnf} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Execute options - -\ExecuteOptions{generic,infoline} -\ProcessOptions - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dimensions - -\setlength\parindent {12\p@} -\setlength\headsep {14\p@} -\setlength\footskip {14\p@} - -\setlength\smallskipamount{6\p@ \@plus 1\p@ \@minus 1\p@} -\setlength\medskipamount {12\p@ \@plus 3\p@ \@minus 3\p@} -\setlength\bigskipamount {18\p@ \@plus 3\p@ \@minus 3\p@} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% setattribute, getattribute, do@option@list - -\def\setattribute{\@ifnextchar[\@setattribute{\@setattribute[]}} -\def\@setattribute[#1]#2#3#4{\expandafter\gdef\csname #2@#3\endcsname{#4}} -\def\getattribute#1#2{\csname #1@#2\endcsname} -\def\sep@key@value#1=#2/?/#3{\setattribute{#3}{#1}{#2}} -\def\do@option@list#1#2{% - \@for\curr@option:={#2}\do{% - \expandafter\sep@key@value\curr@option/?/{#1}\relax - }% -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% newpseudoenvironment -% same as \newenvironment, but new environment do not have additional groups \bgroup \egroup -% (i.e. all definitions are not local - -\let\org@begin\begin -\let\org@end\end -\def\begin#1{% - \@ifundefined{pseudo@#1}% - {\org@begin{#1}}{\csname pseudo@#1\endcsname[0]\relax}% - } -\def\end#1{% - \@ifundefined{pseudo@#1}% - {\org@end{#1}}{\csname pseudo@#1\endcsname[1]\relax}% - } -\def\newpseudoenvironment#1#2#3{% - \expandafter\gdef\csname pseudo@#1\endcsname[##1]{% - \relax\ifcase##1\relax\def\@@next@@{#2}\or\def\@@next@@{#3}\else\let\@@next@@\relax\fi\@@next@@}% - } - - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pubyear, volume, paperno - -\def\pubyear#1{\gdef\@pubyear{(#1) }\gdef\@copyrightyear{#1 }} - \def\@pubyear{} - \def\@copyrightyear{} - -\def\volumetitle#1{\gdef\volume@title{#1 }} - -\def\volume#1{\gdef\@volume{Vol. #1 }} - \gdef\@volume{} - -\def\issue#1{\gdef\@issue{No. #1 }} - \gdef\@issue{} - -\def\paperno#1{\gdef\@paperno{Paper no. #1 }} - \gdef\@paperno{00} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% firstpage, lastpage, pagerange - -\newcounter{firstpage} -\newcounter{lastpage} - -\def\firstpage#1{\def\@tempa{#1}\ifx\@tempa\@empty\else - \global\c@firstpage=#1 - \global\c@lastpage=#1 - \global\c@page=#1 \ignorespaces\fi} - -\def\lastpage#1{\def\@tempa{#1}\ifx\@tempa\@empty\else - \global\c@lastpage=#1 - \ignorespaces\fi} - -\def\pagerange@sep{--} - -\def\set@pagerange{% - \ifnum\c@firstpage=0% - \else% - \ifnum\c@firstpage=\c@lastpage% - \gdef\@pagerange{\thefirstpage}% - \else% - \gdef\@pagerange{\thefirstpage\pagerange@sep\thelastpage}% - \fi% - \fi} - -\def\@pagerange{} - -\def\pagenumbering#1{% - \gdef\thefirstpage{\csname @#1\endcsname\c@firstpage}% - \gdef\thelastpage{\csname @#1\endcsname\c@lastpage}% - \gdef\thepage{\csname @#1\endcsname\c@page}% -} - -% hyperref redefines \pagenumbering, so we must override hyperref definition: -\let\ims@pagenumbering\pagenumbering - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% startlocaldefs, endlocaldefs - -\def\startlocaldefs{\makeatletter} -\def\endlocaldefs{\makeatother} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thanksref, thanksmark, thankslabel, thankstext -% to be safe with hyperref we will use original LaTeX definitions: -% - -\def\saferef#1{\expandafter\safe@setref\csname r@#1\endcsname\@firstoftwo{#1}} -\let\safe@setref\@setref - -\def\safelabel#1{\@bsphack - \protected@write\@auxout{}% - {\string\thanksnewlabel{#1}{{\@currentlabel}{\thepage}}}% - \@esphack} - -\long\def\safe@footnotetext#1{\insert\footins{% - \reset@font\footnotesize - \interlinepenalty\interfootnotelinepenalty - \splittopskip\footnotesep - \splitmaxdepth \dp\strutbox \floatingpenalty \@MM - \hsize\columnwidth \@parboxrestore - \color@begingroup - \def\@thefnmark{}% - \@makefntext{% - \rule\z@\footnotesep\ignorespaces #1\@finalstrut\strutbox}% - \color@endgroup}}% - - -\long\def\orig@footnotetext#1{\insert\footins{% - \reset@font\footnotesize - \interlinepenalty\interfootnotelinepenalty - \splittopskip\footnotesep - \splitmaxdepth \dp\strutbox \floatingpenalty \@MM - \hsize\columnwidth \@parboxrestore - \protected@edef\@currentlabel{% - \csname p@footnote\endcsname\@thefnmark - }% - \color@begingroup - \@makefntext{% - \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}% - \color@endgroup}}% - - - -\let\thanksnewlabel\newlabel - -% we want to use various counters: -\def\usethankscounter#1{% - \@ifundefined{current@thankscounter}{\gdef\previous@thankscounter{#1}}{\xdef\previous@thankscounter{\current@thankscounter}}% - \def\current@thankscounter{#1}} - -\def\restorethankscounter{\xdef\current@thankscounter{\previous@thankscounter}} - -\newcounter{thanks} -\def\thethanks{\@fnsymbol\c@thanks} -\usethankscounter{thanks} - -% address ref: -\newcounter{addressref} -\def\theaddressref{\arabic{addressref}} - - -%\def\thanksmark@fmt#1{\hbox{$^{#1}$}} -\def\thanksmark@fmt#1{\@textsuperscript{\normalfont#1}} -\def\thanksref@sep{,} - -% hooks for the hyperref: -\def\thankref@hyperlink#1{\saferef{#1thanks}} -\def\thanks@hypertarget#1{} - -% Isvedame zymes -\DeclareRobustCommand{\thanksref}{\@ifnextchar[{\@tempswatrue\@thanksref}{\@tempswafalse\@thanksref[]}} - -\def\@thanksref[#1]#2{% - \if@tempswa% [] - \thanksmark@fmt{#1}% - \else% - \let\@tempa\@empty% - \thanksmark@fmt{\@for\@tempb:=#2\do{% - \csname thanksref@hook\endcsname% - \@tempa\let\@tempa\thanksref@sep% - \edef\@tempb{\expandafter\@firstofone\@tempb\@empty}% - \thankref@hyperlink{\@tempb}}}% - \fi} - -% Suformuojame ir isvedame zyme -\def\thanksmark{\@ifnextchar[{\@tempswatrue\@thanksmark}{\@tempswafalse\@thanksmark[]}} - -\def\@thanksmark[#1]#2{% - \@thankslabel[#1]{#2}% - \safelabel{#2thanks}% - \thanksmark@fmt{\expandafter\saferef{#2thanks}\thanks@hypertarget{#2}}} - -% Suformuojame tik zyme -\def\thankslabel{\@ifnextchar[{\@tempswatrue\@thankslabel}{\@tempswafalse\@thankslabel[]}} - -\def\@thankslabel[#1]#2{% - \if@tempswa% [] - \protected@edef\@currentlabel{#1}% - \else% - \refstepcounter{\current@thankscounter}% - \fi% - \safelabel{#2thanks}}% - -% Suformuojame zyme ir idedame teksta i \@thanks: -\def\thankstext{\@ifnextchar[{\@tempswatrue\@thankstext}{\@tempswafalse\@thankstext[]}} - -\def\@thankstext[#1]#2#3{% - \@thankslabel[#1]{#2}% - \protected@xdef\@thanks{\@thanks\protect\thanks@thefnmark{#2thanks}% - \protect\orig@footnotetext{\thanks@hypertarget{#2}#3}}}% - -\def\thanks@thefnmark#1{\begingroup\unrestored@protected@xdef\@thefnmark{\saferef{#1}}\endgroup}% - - - -% ST makrosas savo numeracijos sistemos sukurimui -\def\setvaluelist#1#2{\@tempcnta=0\relax - \@for\@curr@val:=#2\do{% - \advance\@tempcnta by1\relax - \expandafter\protected@xdef\csname #1@item@\the\@tempcnta\endcsname{\@curr@val}% - }% - \expandafter\protected@xdef\csname #1@item@0\endcsname{\the\@tempcnta}% -} -\xdef\getitemvalue#1#2{\noexpand\csname #1@item@#2\endcsname} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ead, \printead - -\RequirePackage{keyval} - -\def\email@text{e-mail: } -\def\url@text{url: } -\def\fullurl@text{url: } -\def\ead@sep{;~} -\let\ead@size\relax -\def\printead@fmt#1{#1} - -% for BJ journal: -\newcounter{emailref} -\setvaluelist{emailmarks}{*,**,\textdagger,\textdaggerdbl} -\def\theemailref{\getitemvalue{emailmarks}{\the\c@emailref}} -\define@key{ead}{mark}[true]{\usethankscounter{emailref}\thankslabel{\ead@label}} - - -% naudojame keyval paketa -\define@key{ead}{email}[true]{\def\ead@type{email}} -\define@key{ead}{url}[true]{\def\@tempa{fullurl}\ifx\ead@type\@tempa\else\def\ead@type{url}\fi} -\define@key{ead}{label}{\def\ead@label{#1}} - -\define@key{ead}{text}{% - \bgroup% - \def\\{\string\break} - \def\break{\string\break}% - \protected@edef\@currentlabel{#1}% - \safelabel{\ead@label @\ead@type text}% - \egroup} - -\define@key{ead}{nopdflink}[true]{% - \protected@edef\@currentlabel{nolink}% - \safelabel{\ead@label @nopdflink}} - - -\DeclareRobustCommand\ead[2][label= ,email]{{% - \def\ead@type{email}% default - \checkead@prefix#2://\end% - \def\texttildelow{\noexpand\texttildelow}% - \setkeys{ead}{#1}% - \protected@edef\@currentlabel{#2}% - \safelabel{\ead@label @\ead@type}}} - -\def\checkead@prefix#1://#2\end{\ifx.#2.\else\def\ead@type{fullurl}\fi} - -\newif\ifnot@ead@star -\newif\if@printead@opt - -\DeclareRobustCommand{\printead}{\@ifstar{\not@ead@starfalse\@printead}{\not@ead@startrue\@printead}} - -\def\@printead{\@ifnextchar[{\@printead@opttrue\@@printead}{\@printead@optfalse\@@printead[]}} - -\def\@@printead[#1]#2{{% - \if@printead@opt%[] - \def\ims@href@text{#1}% - \not@ead@starfalse% - \fi% - \let\prev@ead@text\relax% - \let\@ead@sep\relax% - \let\ead@text\relax% - \let\ead@prefix\relax% - \def\ead@type{}% - \@tempcnta=0% - \let\sv@ims@href\ims@href% - \printead@fmt{\@for\ead@ref:=#2\do{% - \advance\@tempcnta by1% - \let\ims@href\sv@ims@href% - \@ead@sep\let\@ead@sep\ead@sep% - \@ifundefined{r@\ead@ref @nopdflink}{}{\def\ims@href##1##2{##2}}% - \@ifundefined{r@\ead@ref @email}{}{\let\ead@text\email@text\def\ead@type{email}\def\ead@prefix{mailto:}}% - \@ifundefined{r@\ead@ref @url}{}{\let\ead@text\url@text\def\ead@type{url}\def\ead@prefix{http://}}% - \@ifundefined{r@\ead@ref @fullurl}{}{\let\ead@text\fullurl@text\def\ead@type{fullurl}\def\ead@prefix{}}% - \ifx\prev@ead@text\ead@text\let\ead@text\relax\fi% - \if@printead@opt\ifnum\@tempcnta>1\@latex@error{Command \@backslashchar printead[]{e1} could have only one parameter "e1"!}\@eha\fi% - \else\@ifundefined{r@\ead@ref @\ead@type text}{\def\ims@href@text{\@ifundefined{r@\ead@ref thanks}{}{\thanksref{\ead@ref}}\saferef{\ead@ref @\ead@type}}}{\def\ims@href@text{\@ifundefined{r@\ead@ref thanks}{}{\thanksref{\ead@ref}}\saferef{\ead@ref @\ead@type text}}}\fi% - \ifnot@ead@star\ead@text\fi{\ead@size\def\null{}\ims@href{\ead@prefix\saferef{\ead@ref @\ead@type}}{\ims@href@text}}% - \@ifundefined{ead@text}{}{\let\prev@ead@text\ead@text}}}% -}} - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \copyrightowner, \corref - -\def\copyrightowner#1{\def\copyrightowner@text{#1}} - - -% for corresponding author -\def\corref#1{} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% normaltext, nohyphen, today - -% normalus tekstas (justify) -\def\normaltext{\let\\=\@normalcr% - \leftskip\z@ \@rightskip\z@ \rightskip\@rightskip% - \parfillskip\@flushglue} - -% skiemenavimo isjungimas -\def\nohyphen{\pretolerance=\@M \tolerance=\@M \hyphenpenalty=\@M \exhyphenpenalty=\@M} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \@ifemptyhbox - -\def\@ifnonempty#1{% - \setbox\@tempboxa\hbox{\ignorespaces #1}% - \ifdim\wd\@tempboxa>1pt #1\fi} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\pagestyle{imsheadings} \thispagestyle{copyright} - - -\if@twoside - -\def\ps@imsheadings{% - \def\@oddfoot{\hfill\info@line}% - \let\@evenfoot\@oddfoot% - \def\@evenhead{\runninghead@size\rlap{\pagenumber@size\thepage}\evenhead@fmt{\leftmark}}% - \def\@oddhead{\runninghead@size\oddhead@fmt{\rightmark}\llap{\pagenumber@size\thepage}}} -\else -\def\ps@imsheadings{% - \def\@oddfoot{\hfill\info@line}% - \let\@evenfoot\@oddfoot% - \def\@evenhead{\runninghead@size\hfill\leftmark/\rightmark\hfill\llap{\pagenumber@size\thepage}}% - \def\@oddhead{\runninghead@size\hfill\leftmark/\rightmark\hfill\llap{\pagenumber@size\thepage}}} -\fi - -\def\ps@copyright{\let\@mkboth\@gobbletwo% - \def\@evenhead{\parbox[t]{\textwidth}{\copyright@size\copyright@text}}% - \let\@oddhead\@evenhead% - \def\@oddfoot{\hfill\pagenumber@size\thepage\hfill\llap{\info@line}}% - \let\@evenfoot\@oddfoot} - -\def\evenhead@fmt#1{\hfill#1\hfill} -\def\oddhead@fmt#1{\hfill#1\hfill} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% url@fmt - - -\def\journalurl#1{\def\journal@url{#1}} -\def\paperurl#1{\def\paper@url{#1}} - -% DOI - -\def\doi#1{% - \gdef\@doi{#1}% - \gdef\doi@text{\url@fmt{DOI: }{\ttfamily}{#1}{\doi@base\@doi}}% -} - -\let\@doi\relax - -\def\doi@base{http://dx.doi.org/} - -\protected\def\relateddoi{\@ifnextchar[{\@tempswatrue\@relateddoi}{\@tempswafalse\@relateddoi[]}} -\def\@relateddoi[#1]#2#3{\protect\ims@href{\doi@base#3}{#3}}% - -\protected\def\relateddois{\@ifnextchar[{\@tempswatrue\@relateddois}{\@tempswafalse\@relateddois[]}} -\def\@relateddois[#1]#2#3{% - \@thankslabel[#1]{#2}% - \bgroup% - \protected@xdef\@thanks{\@thanks\protect\thanks@thefnmark{#2thanks}% - \protect\@footnotetext{\thanks@hypertarget{#2}#3}}% - \egroup% -}% - -% arXiv - - -\def\arxiv#1{% - \gdef\@arxiv{#1}% - \gdef\doi@text{\url@fmt{arXiv: }{\ttfamily}{#1}{\arxiv@base\@arxiv}}% -} - -\let\@arxiv\relax - -% http://arxiv.org/abs/math.PR/0603300 - -\def\arxiv@base{http://arxiv.org/abs/} - - -% {url}{text} -\def\ims@href#1#2{#2} - -% {prefix}{font}{text}{url} - -\def\url@fmt#1#2#3#4{% - \edef\@tempa{#3}% - \ifx\@tempa\@empty% - \else% - #1{#2\ims@href{#4}{#3}}% - \fi} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LIST ENVIRONMENTS - -\parsep\z@ -\topsep\smallskipamount -\partopsep\z@ -\itemsep\z@ -\labelsep.5em - -\def\@listI{\leftmargin\leftmargini - \parsep\z@ - \topsep\smallskipamount - \itemsep\z@} - -\def\list@parindent{1pc} - -% quotation -\let\quotation@size\footnotesize -\def\quotation@itemindent{\list@parindent} -\def\quotation@parindent{\list@parindent} -\def\quotation@leftmargin{\list@parindent} -\let\quotation@rightmargin\z@ -\let\quotation@topsep\smallskipamount - -\def\quotation{% - \list{}{\quotation@size% - \listparindent\quotation@parindent% - \itemindent \quotation@itemindent% - \rightmargin\quotation@rightmargin \leftmargin\quotation@leftmargin% - \partopsep\z@ \topsep\quotation@topsep \parsep\z@% - }% - \item[\Q@strut]\relax} - -\def\endquotation{\endlist} - -\def\Q@strut{\leavevmode\hbox{\vrule height9pt depth1pt width0pt}} - -% quote -\let\quote@size\footnotesize -\def\quote@indent{\z@} -\def\quote@leftmargin{2pc} -\def\quote@rightmargin{2pc} -\let\quote@topsep\smallskipamount - -\def\quote{% - \list{}{\quote@size% - \listparindent\quote@indent% - \itemindent \listparindent% - \rightmargin\quote@rightmargin \leftmargin\quote@leftmargin% - \partopsep\z@ \topsep\quote@topsep \parsep\z@% - }% - \item\relax} - -\def\endquote{\endlist} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% table, figure - -\def\fnum@table{\tablename~\thetable} -\setlength\belowcaptionskip{4\p@} - -\renewenvironment{table} - {\let\@makecaption\@maketablecaption\@float{table}} - {\end@float} -\renewenvironment{table*} - {\let\@makecaption\@maketablecaption\@dblfloat{table}} - {\end@dblfloat} - -\long\def\@maketablecaption#1#2{% - \tablecaption@shape\tablecaption@size% - {\tablename@size #1}\tablename@skip #2\par - \vskip\belowcaptionskip} - -\setattribute{tablecaption}{shape}{\centering} -\setattribute{tablecaption}{size} {\footnotesize\itshape} -\setattribute{tablename} {size} {\scshape} -\setattribute{tablename} {skip} {\endgraf} - - -% figure : use \@makecaption: -\renewcommand\figurename{Fig} - -\long\def\@makecaption#1#2{% - \vskip\abovecaptionskip - \footnotesize - \sbox\@tempboxa{\itshape\textsc{#1}. #2}% - \ifdim \wd\@tempboxa >\hsize - \itshape\textsc{#1}. #2\par - \else - \global \@minipagefalse - \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% - \fi - \vskip\belowcaptionskip} - -\long\def\@makecaption#1#2{% - \vskip\abovecaptionskip - \figurecaption@size - \sbox\@tempboxa{{\figurename@size #1}\figurename@skip #2}% - \ifdim \wd\@tempboxa >\hsize - {\figurename@size #1}\figurename@skip #2\par - \else - \global \@minipagefalse - \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% - \fi - \vskip\belowcaptionskip} - -\setattribute{figurecaption}{size}{\footnotesize\itshape} -\setattribute{figurename} {size}{\scshape} -\setattribute{figurename} {skip}{.~} - - -\def\@floatboxreset{% - \reset@font - \@setminipage - \singlespacing - \footnotesize - \centering -} - -\if@aihplayout - \setattribute{tablecaption}{size} {\footnotesize} - \setattribute{figurecaption}{size}{\footnotesize} -\fi - -\if@bjpslayout - \setattribute{tablename} {size} {\bfseries\upshape} - \setattribute{tablename} {skip} {\enskip} - - \setattribute{figurename} {size}{\bfseries\upshape} - \setattribute{figurename} {skip}{\enskip} - \def\figurename{Figure} -\fi - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FOOTNOTE - -\renewcommand\@makefntext[1]{% - \parindent12pt\@makefnmark #1} - -\def\@makefnmark{\@textsuperscript{\normalfont\@thefnmark}}% - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION commands: -% from latex.ltx: -% Two improvements: -% 1. if section command is defined as "inline" the '.' will be inserted after heading; -% 2. section* will write to toc and will appear in pdf bookmarks - -% dirty trick... -\def\@startsection#1#2#3#4#5#6{% - \if@noskipsec \leavevmode \fi - \par - \@tempskipa #4\relax - \@afterindenttrue - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \fi - \if@nobreak - \everypar{}% - \else - \addpenalty\@secpenalty\addvspace\@tempskipa - \fi - \@ifstar - {\def\ssection@level{#2}\@ssect{#3}{#4}{#5}{#6}}% - {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} - -% Trick for the hyperref: -\def\setaftersec@dot#1{\if@autosecdot\setbox0=\hbox{#1}\ifdim\wd0>0\p@\def\aftersec@dot{.}\else\def\aftersec@dot{}\fi\fi} -\let\aftersec@dot\relax - -% section - will add hook for the dot after section heading -\def\@sect#1#2#3#4#5#6[#7]#8{% - \ifnum #2>\c@secnumdepth - \let\@svsec\@empty - \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% - \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ - \begingroup - #6{% - \@hangfrom{\hskip #3\relax\@svsec}% - \interlinepenalty \@M #8\@@par}% - \endgroup - \csname #1mark\endcsname{#7}% - \addcontentsline{toc}{#1}{% - \ifnum #2>\c@secnumdepth \else - \protect\numberline{\csname the#1\endcsname}% - \fi - #7}% - \else - \setaftersec@dot{#8}% - \def\@svsechd{% - #6{\hskip #3\relax - \@svsec #8\aftersec@dot}% - \csname #1mark\endcsname{#7}% - \addcontentsline{toc}{#1}{% - \ifnum #2>\c@secnumdepth \else - \protect\numberline{\csname the#1\endcsname}% - \fi - #7}}% - \fi - \@xsect{#5}} - -% section* - will add hook for the dot after section heading and \contentsline -\def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ - \begingroup - #4{% - \@hangfrom{\hskip #1}% - \interlinepenalty \@M #5\@@par}% - \endgroup - \else - \setaftersec@dot{#5}% - \def\@svsechd{#4{\hskip #1\relax #5\aftersec@dot}}% - \fi - \ifnum\ssection@level=1\phantomsection\addcontentsline{toc}{section}{#5}\fi% - \@xsect{#3}} - -% Block adding to contents for the next command only: -\def\nocontentsline{% - \let\@@addcontentsline\addcontentsline% - \ifx\hyper@anchor\@undefined - \def\addcontentsline##1##2##3{\let\addcontentsline\@@addcontentsline} - \else - \def\addcontentsline##1##2##3##4{\let\addcontentsline\@@addcontentsline} - \fi -} - -\def\qq#1{% - \bgroup% - \ifx.#1.\relax% - \ifmmode% - \mbox{\normalfont\textbf{???}} - \else% - \normalfont\textbf{???}\fi - \else% - \ifmmode% - \mbox{\normalfont\textbf{#1}}% - \else% - \normalfont\textbf{#1}% - \fi% - \fi% - \egroup% -} - -% \phantomsection is defined in hyperref -\let\phantomsection\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER SETTINGS - -% FRONT MATTER FORMATTING PARAMETERS - -\setattribute{frontmatter} {style} {\centering} -\setattribute{title} {style} {\centering\def\\{\break}} -\setattribute{author} {style} {\centering} -\setattribute{address} {style} {\centering} -\setattribute{abstract} {style} {\normaltext} -\setattribute{keyword} {style} {\normaltext} -\setattribute{history} {style} {\normaltext} - -% FRONT MATTER SKIPS -\setattribute{title} {skip} {18\p@} -\setattribute{atltitle} {skip} {14\p@} -\setattribute{authors} {skip} {12pt} -\setattribute{dedicated} {skip} {12\p@} -\setattribute{address} {skip} {6\p@ plus 1\p@ minus 1\p@} -\setattribute{affiliation} {skip} {6\p@ plus 1\p@ minus 1\p@} -\setattribute{abstract} {skip} {10\p@} -\setattribute{abstractname}{skip} {:\enskip} -\setattribute{keyword} {skip} {10\p@} -\setattribute{history} {skip} {10\p@} -\setattribute{frontmatter} {cmd} {\vskip20\p@ plus 3\p@ minus 3\p@ - \@afterindentfalse\@afterheading} -\setattribute{firstpage} {cmd} {} - -% FRONT MATTER DIMENSIONS -\setattribute{abstract} {width} {.8\textwidth} -\setattribute{abstract} {indent} {0\p@} -\setattribute{keyword} {width} {.8\textwidth} -\setattribute{keyword} {indent} {0\p@} % -\setattribute{history} {width} {.8\textwidth} - -% FRONT MATTER FONTS -\setattribute{dochead} {size} {\Large\bfseries} -\setattribute{title} {size} {\LARGE\bfseries} -\setattribute{author} {size} {\normalsize\bfseries} -\setattribute{fnms} {size} {} -\setattribute{snm} {size} {} -\setattribute{address} {size} {\footnotesize\itshape\mdseries} -\setattribute{affiliation}{size} {\footnotesize\itshape\mdseries} -\setattribute{dedicated} {size} {\normalsize\itshape} -\setattribute{ead} {size} {\upshape\ttfamily} -\setattribute{abstract} {size} {\footnotesize\upshape\mdseries} -\setattribute{abstractname}{size} {\bfseries} -\setattribute{keyword} {size} {\footnotesize\upshape\mdseries} -\setattribute{keywordname}{size} {\bfseries} -\setattribute{history} {size} {\footnotesize\mdseries} -\setattribute{copyright} {size} {\footnotesize\raggedright} -\setattribute{runninghead}{size} {\footnotesize\itshape} -\setattribute{pagenumber} {size} {\footnotesize\upshape} -\setattribute{thebibliography}{size}{\normalsize} - -% FRONT MATTER CASE -\setattribute{dochead} {case} {} -\setattribute{title} {case} {} -\setattribute{runninghead}{case} {} - -% TEXT, etc. -\setattribute{doi} {text} {\url@fmt{url: }{\ttfamily}{\paper@url}{\paper@url}} -\setattribute{copyright} {text} {\url@fmt{}{\bfseries}{\journal@name}{\journal@url}\break% - \@ifundefined{volume@title}{}{\textbf{\volume@title}\break}% - \@ifnonempty{\@volume\@pubyear\@pagerange\break}% - \@ifnonempty{\journal@issn\break}% - \doi@text}% - -\setattribute{infoline} {text} {\lower12pt \hbox{\footnotesize\ttfamily\imsfmt@name\journal@id\ ver. \imsfmt@version\ file: \jobname.tex\ date: \today}} -\setattribute{copyright} {owner} {$\copyright$~\@copyrightyear \copyrightowner@text} -\setattribute{author} {prefix} {} -\setattribute{keyword} {postfix} {\unskip.} - -\def\abstractname{Abstract} - -% HISTORY -\setattribute{history} {prefix} {} -\setattribute{history} {postfix} {.} -\setattribute{received} {prefix} {Received~} -\setattribute{received} {postfix} {} -\setattribute{revised} {prefix} {; revised~} -\setattribute{revised} {postfix} {} -\setattribute{accepted} {prefix} {; accepted~} -\setattribute{accepted} {postfix} {} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER STUFF - -% COUNTERS, ETC -\newcounter{author} -\newcounter{address} -\newdimen\sv@mathsurround -\def\author@num{0} - -% RUNNING HEAD -\def\runtitle#1{\gdef\@runtitle{\runninghead@case{#1}}} \def\@runtitle{} -\def\runauthor#1{{\def\etal{et al.}\gdef\@runauthor{\runninghead@case{#1}}}} \def\@runauthor{} - -\newdimen\sv@parindent -\sv@parindent\parindent - -\newbox\fm@box -\newdimen\fm@size - -\let\hy@frontmatter\relax -\let\hy@endfrontmatter\relax -\let\tableofcontents@fmt\relax - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER - -\def\frontmatter{% - \global\c@author\z@ - \global\c@address\z@ - \renewcommand\thefootnote{\@fnsymbol\c@footnote}% -% - \if@changetoc - \let\old@tableofcontents\tableofcontents% - \def\tableofcontents{\let\tableofcontents@fmt\old@tableofcontents}% - \fi -% - \def\pdftitle##1{\write@pdfinfo{\user@hy@title}{##1}} - \def\pdfauthor##1{\write@pdfinfo{\user@hy@author}{##1}} - \def\pdfsubject##1{\write@pdfinfo{\user@hy@subject}{##1}} - \def\pdfkeywords##1{\write@pdfinfo{\user@hy@keywords}{##1}} -% - \if@supertoc% - \addtocontents{toc}{\protect\contentsline{begintocitem}{}{}{}}% - \addtocontents{toc}{\protect\contentsline{jobname}{\jobname}{}{}} - \ifx\@doi\relax \else\addtocontents{toc}{\protect\contentsline{doi}{\@doi}{}{}}\fi% - \ifx\@arxiv\relax \else\addtocontents{toc}{\protect\contentsline{arxiv}{\@arxiv}{}{}}\fi% - \fi -% - \sv@mathsurround\mathsurround \m@th - \parindent\z@ - \hy@frontmatter - \global\let\maketitle\relax - \open@fm \ignorespaces} -% -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ENDFRONTMATTER - -\def\endfrontmatter{% - \global\@topnum\z@ - \set@pagerange - \markboth{\@runauthor}{\@runtitle}% - \thispagestyle{copyright}% -% - \put@fmt@data% -% - \close@fm -% - \firstpage@cmd -% - \write@pdfinfo{\hy@author}{\the\authors@list} - \write@pdfinfo{\hy@subject}{\journal@name\@copyrightyear\@volume\@issue\@pagerange} - \write@pdfinfo{\hy@keywords}{\the\keywords@list} -% - \if@supertoc% - \addtocontents{toc}{\protect\contentsline{author}{\the\authors@list}{\thepage}{}}% - \addtocontents{toc}{\protect\contentsline{endtocitem}{}{}{}}% - \fi% -% - \write\@mainaux{\string\gdef\string\author@num{\the\c@author}} - \hy@endfrontmatter - \global\mathsurround\sv@mathsurround - \global\c@footnote\z@ - \global\let\@thanks\@empty - \let\title\relax - \let\author\relax - \let\address\relax - \let\frontmatter\relax \let\endfrontmatter\relax - \let\@maketitle\relax \let\@@maketitle\relax - \aftergroup\frontmatter@cmd - } - - -\def\put@fmt@data{% - \copyright@fmt% - \@thanks% - \abstract@fmt% - \keyword@fmt% - \history@fmt - \tableofcontents@fmt} - - -\newdimen\t@xtheight -\def\init@settings{ -\splittopskip=\topskip \splitmaxdepth=\maxdepth -\t@xtheight\textheight \advance\t@xtheight-\splittopskip} - -\def\no@harm{\let\thanks=\@gobble\let\thanksref=\@gobble\let~\space\def\ead[##1]##2{}\let\\=\@empty \def\protect{\noexpand\protect\noexpand}} - -\def\open@fm{% - \global\setbox\fm@box=\vbox\bgroup - \hsize=\textwidth - \frontmatter@style} - -\def\close@fm{% - \par \egroup - \fm@size=\dp\fm@box \advance\fm@size by \ht\fm@box - \@whiledim\fm@size>\t@xtheight \do{% - \global\setbox\@tempboxa=\vsplit\fm@box to \t@xtheight - \unvbox\@tempboxa - \fm@size=\dp\fm@box \advance\fm@size by \ht\fm@box} - \if@twocolumn - \emergencystretch=1pc \twocolumn[\unvbox\fm@box] - \else - \unvbox\fm@box - \fi} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOCHEAD -\def\dochead#1{% - \bgroup - \dochead@size - \leavevmode\vphantom{\strut}\dochead@case{#1}\par - \egroup - \setattribute{title}{skip}{8\p@}} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TITLE -\def\title#1{% - \vglue\title@skip% -% check if we are in {frontmatter} - \def\reserved@a{frontmatter} - \ifx\reserved@a\@currenvir \else \hy@frontmatter\fi - \bgroup% - \no@harm% - \xdef\@argi{#1}% - \xdef\@title{#1}% - \egroup% - \write@pdfinfo{\hy@title}{\@argi} - \if@supertoc% - \addtocontents{toc}{\protect\contentsline{title}{\@argi}{\thepage}{}}% - \fi% - \bgroup% - \title@style\title@size\title@case{#1}\par% - \egroup} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ATLTITLE - -\def\atltitle#1{% - \vglue\atltitle@skip% - \bgroup - \title@size #1\par% - \egroup} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AUTHOR - -% AUG - author block -\def\smart@par{\ifhmode\par\fi} -\newenvironment{aug}{}{\smart@par} - - -\def\and{\unskip~and~} - -\def\author{\@ifnextchar[{\author@fmt}{\author@fmt[]}} - -\def\author@fmt[#1]#2{% - \stepcounter{author}% - \author@fmt@init% - \let\author@fmt@init\relax% - \bgroup% - \def\degs##1{##1}\def\fnms##1{##1}\def\inits##1{##1}\def\snm##1{##1}\def\roles##1{##1}% - \@tempcnta=\author@num\relax% - \ifnum\c@author=\@tempcnta \def\author@sep{ and }\else \def\author@sep{, }\fi% - \ifnum\c@author=1\addto@authors@list{#2}\else\addto@authors@list{\author@sep #2}\fi% - \def\fnms##1{{\fnms@size{##1}}}\def\snm##1{\snm@size{##1}}% - \noindent#2\thanksref{#1}% - \egroup} - -\def\author@fmt@init{% - \vskip\authors@skip% - \noindent\leavevmode\author@style\author@size\author@prefix } - -\let\author@fmt@init@def\author@fmt@init - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEDICATED -\def\dedicated#1{% - \vskip\dedicated@skip - \bgroup - \dedicated@size #1\par - \egroup} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADDRESS -\def\address{\@ifnextchar[{\address@fmt}{\address@fmt[]}} - -\def\address@fmt[#1]#2{% - \smart@par% - \let\author@fmt@init\author@fmt@init@def - \vskip\address@skip% - {\address@style\address@size\leavevmode\ifx.#1.\else\usethankscounter{addressref}\thanksmark{#1}\restorethankscounter\fi#2\par}} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AFFILIATION - -\def\affiliation{\@ifnextchar[{\affiliation@fmt}{\affiliation@fmt[]}} - -\def\affiliation@fmt[#1]#2{% - \smart@par% - \let\author@fmt@init\author@fmt@init@def% - \vskip\affiliation@skip% - \def\affiliation@skip{\z@}% - \bgroup - \affiliation@size% - \leavevmode% - \ifx.#1.\else\usethankscounter{addressref}\thanksmark{#1}\restorethankscounter\fi% - #2\par - \egroup -} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTRIBUTOR -% For LNMS we must write as index entry: -% \contributor{Author, F.}{University} -% \indexentry{Author, F., \textit {Some University}}{} - -\let\contributor\@gobbletwo -\if@supertoc - \def\contributor#1#2{% - \addtocontents{idx}{\protect\indexentry{#1, \protect\textit{#2}}{}}% - } -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COPYRIGHTOWNER - -\def\copyright@fmt{% - \@ifundefined{\copyrightowner@text}{}{\safe@footnotetext{\copyright@owner}} - } - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ABSTRACT - -\newbox\abstract@box - -\define@key{abstract}{language}{\set@loc@hyphenation{#1}\set@loc@abstractname{#1}} - -\gdef\abstract{\@ifnextchar[{\@abstract}{\@abstract[]}} - -\def\@abstract[#1]{% - \setkeys{abstract}{#1}% - \global\setbox\abstract@box=\vbox\bgroup% - \ifvoid\abstract@box\else% - \unvbox\abstract@box% - \vskip\abstract@skip% - \fi% - \@tempdima\textwidth% - \advance\@tempdima by-\abstract@width% - \divide\@tempdima by2% - \abstract@style% - \leftskip\@tempdima\rightskip\@tempdima% - \abstract@size% - \parindent\sv@parindent% - \noindent\hskip\abstract@indent{\abstractname@size\abstractname\abstractname@skip}\ignorespaces} - -\def\endabstract{\par\egroup} - -\def\abstract@fmt{% - \ifvoid\abstract@box\else - \vskip\abstract@skip% - \unvbox\abstract@box - \fi} - -\def\set@loc@hyphenation#1{% - \@ifundefined{l@#1}{}{\expandafter\language\csname l@#1\endcsname}} - -\def\set@loc@abstractname#1{% - \def\abstractname@english{Abstract} - \def\abstractname@german{Zusammenfassung} - \def\abstractname@french{R\'esum\'e} - \def\abstractname@spanish{Resumen.} - \@ifundefined{abstractname@#1}% - {\@latex@error{Nera kalbos '#1` palaikymo!}{}}% - {\edef\abstractname{\csname abstractname@#1\endcsname}}% -} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HISTORY: received, revised, accepted - -\def\history@exist{0} - -\def\received#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@received{#1}\gdef\history@exist{1}\fi} - \def\@received{\@nil} -\def\revised#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@revised{#1}\gdef\history@exist{1}\fi} - \def\@revised{\@nil} -\def\accepted#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@accepted{#1}\gdef\history@exist{1}\fi} - \def\@accepted{\@nil} - -\def\empty@data{\@nil} - -\def\history@fmt{% - \ifcase\history@exist\else% - \bgroup - \nobreak% - \vskip\history@skip% - \nobreak% - \history@style% - \history@size% - \@tempdima\textwidth% - \advance\@tempdima by-\history@width% - \divide\@tempdima by2% - \leftskip\@tempdima - \rightskip\@tempdima - \leavevmode - \history@prefix - \ifx\@received\empty@data \else - \received@prefix\@received \received@postfix% - \fi - \ifx\@revised\empty@data \else - \revised@prefix\@revised \revised@postfix% - \fi - \ifx\@accepted\empty@data \else - \accepted@prefix\@accepted \accepted@postfix% - \fi - \history@postfix\par% - \egroup% - \gdef\history@exist{0} -\fi -} - -\def\sday#1{#1} -\def\smonth#1{\@ifundefined{month@item@#1}% - {\@latex@error{Nera tokio menesio, kurio numeris #1!}{??}}% - {\getitemvalue{month}{#1}}% - }% -\def\syear#1{#1} -\setvaluelist{month}{January,February,March,April,May,June,July,August,September,October,November,December} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% KEYWORDS - -\newbox\keyword@box -\newdimen\pre@kwd@depth - -\setattribute{keyword}{AMS}{AMS 2000 subject classifications:} -\setattribute{keyword}{MSC}{MSC 2010 subject classifications:} -\setattribute{keyword}{MSC2010}{MSC 2010 subject classifications:} - -\setattribute{keyword}{KWD}{Keywords and phrases:} -% raktas=class -\setattribute[default]{keyword}{class}{KWD} - -% \keyword@class-> KWD -% \keyword@KWD -> AMS 2000... - -\gdef\keyword{\@ifnextchar[{\@keyword}{\@keyword[class=KWD]}} - -\gdef\@keyword[#1]{% - \do@option@list{keyword}{#1}% - \def\keyword@name{\csname keyword@\keyword@class\endcsname}% - \let\kwd@sep\relax -% - \global\setbox\keyword@box=\vbox\bgroup% - \ifvoid\keyword@box\else% - \unvbox\keyword@box - \vskip-\pre@kwd@depth\vtop to\pre@kwd@depth{}% - \fi - \@tempdima\textwidth% - \advance\@tempdima by-\keyword@width% - \divide\@tempdima by2% - \keyword@style% - \leftskip\@tempdima\rightskip\@tempdima% - \keyword@size% - \parindent\sv@parindent% - \noindent\hskip\keyword@indent{\keywordname@size\keyword@name}\space\hskip.1pt} - -\def\endkeyword{\keyword@postfix\par\global\pre@kwd@depth\prevdepth\egroup} - -\def\keyword@fmt{% - \ifvoid\keyword@box\else - \vskip\keyword@skip% - \unvbox\keyword@box - \fi} - - -% \kwd[; ]{foo} - \def\sep{\unskip\string, }% - \newif\if@firstkeywordinlist \@firstkeywordinlisttrue - - \DeclareRobustCommand*\kwd{\@ifnextchar[\@kwd{\@kwd[\kwd@sep]}}% - \def\@kwd[#1]#2{\unskip#1{#2}\if@firstkeywordinlist\addto@keywords@list{#2}\@firstkeywordinlistfalse\else\addto@keywords@list{, #2}\fi\let\kwd@sep\sep}% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \maketitle -% if \frontmatter is not used, we will redefine \maketitle - -\def\local@maketitle{% - \global\@topnum\z@ - \set@pagerange - \markboth{\@runauthor}{\@runtitle}% - \thispagestyle{copyright}% -% - \put@fmt@data% -% -% \print@titlepage -% - \write@pdfinfo{\hy@author}{\the\authors@list} - \write@pdfinfo{\hy@keywords}{\the\keywords@list} - \hy@endfrontmatter - \global\mathsurround\sv@mathsurround - \global\c@footnote\z@ - \global\let\@thanks\@empty - \let\title\relax - \let\author\relax - \let\address\relax - \let\frontmatter\relax \let\endfrontmatter\relax - \let\@maketitle\relax \let\@@maketitle\relax - \normalfont\normaltext - \parindent\sv@parindent - \frontmatter@cmd - } - -\AtBeginDocument{\let\maketitle\local@maketitle} - - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROCESS LAYOUT OPTIONS - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put keywords as footnote -\if@keywordsasfootnote - - \newtoks\keyword@toks - - \newpseudoenvironment{keyword}{\gdef\keyword@exist{1}\get@keyword@toks}{} - - \def\get@keyword@toks#1\end{\keyword@toks=\expandafter{\the\keyword@toks\keyword#1\endkeyword}\@gobble} - - \def\keyword@exist{0} - - \gdef\keyword#1{\@ifnextchar[{\@keyword}{\@keyword[class=KWD]}} - - \gdef\@keyword[#1]{% - \do@option@list{keyword}{#1}% - \def\keyword@name{\csname keyword@\keyword@class\endcsname}% - \let\kwd@sep\relax% - \keyword@style% - \keyword@size% - \parindent\sv@parindent% - \pre@kwd% - \hbox{\keywordname@size\keyword@name}\space\hskip.1pt}% - - \gdef\endkeyword{\gdef\pre@kwd{\par\leavevmode}} - - \let\pre@kwd\relax - - \def\keyword@fmt{\ifcase\keyword@exist\else\safe@footnotetext{\the\keyword@toks}\fi} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put history as footnote -\if@historyasfootnote - - \def\history@fmt{% - \ifcase\history@exist\else% - \safe@footnotetext{% - \nobreak% - \history@style% - \history@size% - \leavevmode - \history@prefix - \ifx\@received\empty@data \else - \received@prefix\@received \received@postfix% - \fi - \ifx\@revised\empty@data \else - \revised@prefix\@revised \revised@postfix% - \fi - \ifx\@accepted\empty@data \else - \accepted@prefix\@accepted \accepted@postfix% - \fi - \history@postfix}%\par}% - \fi} - - - - - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put address as footnote -\if@addressasfootnote - \def\address@fmt[#1]#2{% - \ifx.#1.% - \safe@footnotetext{#2} - \else% - \usethankscounter{addressref}% - \bgroup - \def\\{\hfill\break} - \thankstext{#1}{#2}% - \egroup - \restorethankscounter% - \fi% - } -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put address at end -\if@addressatend -\def\address{\@ifnextchar[{\address@fmt}{\address@fmt[default]}} -% -% \def\address@ref@A=1 -% \newtoks\@address@1 -% \@address@1={#2} -% -\def\address@fmt[#1]#2{% - \stepcounter{address}% - \expandafter\protected@xdef\csname address@ref@#1\endcsname{\the\c@address}% - \expandafter\newtoks\csname @address@\the\c@address\endcsname - \expandafter\expandafter\expandafter\global\csname @address@\the\c@address\endcsname={#2}} - -\let\safe@phantomsection\@gobble - -% print address by number: \printaddressnum{1} -\def\printaddressnum#1{% -\xdef\@tmp{#1}% -\bgroup -\@ifundefined{@address@#1}{\@latex@error{Error: there are no address with number '#1'!}{??}}{ - \address@size - \ifnum#1=1% - \safe@phantomsection{\addcontentsline{toc}{section}{Author's addresses}}% - \fi% - \begin{tabular}[t]{@{}l@{}} - \expandafter\expandafter\expandafter\the\csname @address@\@tmp\endcsname - \end{tabular}} -\egroup -} - -% print all addresses: -\def\address@par{\par\vskip3pt} - -\def\printaddresses{% -\vskip\address@skip% -%\addcontentsline{toc}{section}{Author's addresses}% -\def\last@right@glue{\par}% -\ifodd\c@address \def\last@right@glue{\hfill\hbox{}\address@par} \fi% -\ifnum\c@address=1 \def\last@right@glue{\address@par}\fi% -\@tempcnta=0% -\bgroup\parindent\z@ -\@whilenum{\@tempcnta<\c@address}% - \do{% - \advance\@tempcnta\@ne - \ifodd\@tempcnta \def\left@glue{} \def\right@glue{} % nelyginis - \else \def\left@glue{\hfill} \def\right@glue{\address@par}\fi % lyginis - \ifnum\@tempcnta=\c@address \let\left@glue\hfill \let\right@glue\last@right@glue\fi %paskutinis narys - \left@glue\expandafter\printaddressnum{\the\@tempcnta}\right@glue% - } -\egroup -} - -% invoke \printaddresses at end of document: -\let\old@enddocument\enddocument -\def\enddocument{\printaddresses\old@enddocument} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the IMS journals (AOP, AAP, AOS) layout: -\if@imslayout - - \setattribute{title} {skip} {12\p@} - \setattribute{abstractname}{skip} {} - \setattribute{frontmatter} {cmd} {\vskip20\p@ plus 3\p@ minus 3\p@} - - \setattribute{abstract} {width} {23pc} - \setattribute{abstract} {indent} {16pt} %2em - - \setattribute{title} {size} {\normalsize\bfseries\mathversion{bold}\spaceskip.5em} - \setattribute{author} {size} {\normalsize\scshape} - \setattribute{affiliation}{size} {\normalsize\itshape} - \setattribute{address} {size} {\scriptsize\scshape} - \setattribute{ead} {size} {\upshape} - \setattribute{abstractname}{size}{\itshape} - \setattribute{keywordname}{size} {\itshape} - \setattribute{runninghead}{size} {\footnotesize} - \setattribute{pagenumber} {size} {\small} - \setattribute{copyright} {size} {\fontsize{6}{7}\selectfont\raggedright} - \setattribute{thebibliography}{size}{\footnotesize} - - \setattribute{dochead} {case} {\MakeUppercase} - \setattribute{title} {case} {\MakeUppercase} - \setattribute{runninghead}{case} {\MakeUppercase} - - \setattribute{author} {prefix} {By~} - - \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% - \@ifnonempty{\@copyrightyear\@volume\@issue\@pagerange\break}% - \doi@text} - - \setattribute{email} {text} {E-mail: } - \setattribute{url} {text} {URL: } - \setattribute{fullurl} {text} {URL: } - \def\volume#1{\gdef\@volume{Vol. #1, }} - \def\issue#1 {\gdef\@issue{No. #1, }} - \def\pubyear#1{\gdef\@pubyear{#1,}\gdef\@copyrightyear{#1 }} - - \def\abstractname{} - - \def\put@fmt@data{% - \copyright@fmt% - \history@fmt - \@thanks% - \keyword@fmt% - \abstract@fmt% - } - - \def\contentsname@cmd{\specialsection*{\contentsname}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the STS journal layout: - -\if@stslayout - - \setattribute{frontmatter} {style} {\raggedright} - \setattribute{title} {style} {\noindent\raggedright} - \setattribute{author} {style} {\noindent\raggedright} - \setattribute{address} {style} {\raggedright} - - \setattribute{title} {skip} {6\p@} - \setattribute{authors} {skip} {10pt} - \setattribute{address} {skip} {\z@} - \setattribute{abstract} {skip} {36\p@} - \setattribute{abstractname}{skip} {. } - \setattribute{keyword} {skip} {8\p@} - - \setattribute{abstract} {width} {28pc} - \setattribute{keyword} {width} {28pc} - - \setattribute{dochead} {size} {\sffamily\Large\fontseries{bx}\selectfont\spaceskip.5em} - \setattribute{title} {size} {\sffamily\fontseries{bx}\fontsize{24.88}{26}\selectfont\mathversion{bold}\spaceskip.5em} - \setattribute{author} {size} {\sffamily\large\fontseries{bx}\selectfont} - \setattribute{address} {size} {\normalfont\normalsize\itshape} - \setattribute{affiliation} {size} {\small\mdseries} - \setattribute{ead} {size} {} - \setattribute{abstract} {size} {\normalsize\mdseries\upshape} - \setattribute{abstractname} {size} {\itshape} - \setattribute{keyword} {size} {\normalsize\mdseries\upshape} - \setattribute{keywordname} {size} {\itshape} - \setattribute{thebibliography}{size} {\footnotesize} - \setattribute{copyright} {size} {\normalfont\mdseries\fontsize{6}{7}\selectfont\raggedright} - \setattribute{runninghead} {size} {\footnotesize} - \setattribute{runninghead} {case} {\MakeUppercase} - \setattribute{pagenumber} {size} {\small\bfseries} - - \setattribute{keyword} {KWD}{Key words and phrases:} - -% \printead: - \def\printead@fmt#1{(#1)} - -% all addresses are combined: - \newtoks\address@toks - - \def\address@exist{0} - - \def\address{\@ifnextchar[{\@address}{\@address[]}} - - \def\@address[#1]#2{ - \gdef\address@exist{1} - \begingroup% - \no@harm% - \xdef\@act{\global\noexpand\address@toks{\the\address@toks#2\ }}\@act - \endgroup} - - \def\address@fmt{\ifcase\address@exist\else\safe@footnotetext{\hskip-\parindent\address@style\address@size\the\address@toks}\fi} - - \def\put@fmt@data{% - \copyright@fmt% - \address@fmt% - \@thanks% - \abstract@fmt% - \keyword@fmt% - \if@twocolumn% - \frontmatter@cmd% - \fi} - - \def\firstpage@cmd{% - \if@twocolumn - \markboth{\@runauthor}{\@runtitle}% - \address@fmt% - \@thanks - \fi} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the BJ journal layout: - -\if@bjlayout - - \setattribute{frontmatter} {style} {\raggedright} - \setattribute{title} {style} {\noindent\raggedright} - \setattribute{author} {style} {\noindent\raggedright} - \setattribute{address} {style} {\raggedright} - - \setattribute{title} {skip} {10\p@} - \setattribute{abstract} {skip} {16\p@} - \setattribute{abstractname}{skip} {} - - \setattribute{abstract} {width} {\textwidth} - \setattribute{keyword} {width} {\textwidth} - \setattribute{history} {width} {\textwidth} - - \setattribute{dochead} {size} {\normalsize\MakeUppercase} - \setattribute{title} {size} {\fontsize{21}{26}\selectfont} - \setattribute{author} {size} {\normalsize} - \setattribute{fnms} {size} {\uppercase} - \setattribute{snm} {size} {\uppercase} - - \setattribute{address} {size} {\small\itshape} - \setattribute{abstract} {size} {\small\upshape} - \setattribute{keyword} {size} {\small\upshape} - \setattribute{keywordname}{size} {\itshape} - \setattribute{history} {size} {\raggedright\small\itshape} - - \setattribute{runninghead}{size} {\normalsize\itshape} - \setattribute{pagenumber} {size} {\normalsize\upshape} - \setattribute{copyright} {size} {\normalsize} - \setattribute{footline} {size} {\footnotesize} - - \setattribute{email} {text} {E-mail:~} - \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\ \textbf{\@volume}\@issue\@pubyear\ \@pagerange\\ - \doi@text} - \setattribute{history} {postfix} {} - \setattribute{revised} {prefix} { and revised~} - - \setattribute{keyword}{KWD}{Keywords:} - - \def\put@fmt@data{% - \copyright@fmt% - \@thanks% - \abstract@fmt% - \keyword@fmt% - \tableofcontents@fmt} - - % invoke \printhistory at end of document: - \let\old@enddocument\enddocument - \def\enddocument{\history@fmt\old@enddocument} - - \def\volume#1{\gdef\@volume{#1}} - \def\issue#1{\gdef\@issue{(#1)}} - \def\pubyear#1{\gdef\@pubyear{, #1, }\gdef\@copyrightyear{, #1, }} - - \def\abstractname{} - - \def\evenhead@fmt#1{\hfill#1} - \def\oddhead@fmt#1{#1\hfill} - - \def\fnum@table{\tablename~\thetable.} - - \long\def\@maketablecaption#1#2{% - \centering\footnotesize - \textbf{#1}\enskip #2\par - \vskip\belowcaptionskip} - - \renewcommand\figurename{Figure} - - \long\def\@makecaption#1#2{% - \vskip\abovecaptionskip - \footnotesize - \textbf{#1}. #2\par - \vskip\belowcaptionskip} - - -\fi - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the AIHP journal layout: - -\if@aihplayout - - % FRONT MATTER SKIPS - \setattribute{title} {skip} {64\p@} - \setattribute{authors} {skip} {14\p@} - \setattribute{address} {skip} {12\p@} - \setattribute{abstractname}{skip} {.\enskip} - \setattribute{history} {skip} {4\p@} - \setattribute{abstract} {skip} {16\p@} - - \setattribute{fline} {cmd} {\vskip22\p@ - \hrule} - \setattribute{lline} {cmd} {\vskip10\p@ - \hrule} - - % FRONT MATTER DIMENSIONS - \setattribute{abstract} {width} {\textwidth} - \setattribute{abstract} {indent} {\z@} - \setattribute{keyword} {width} {\textwidth} - \setattribute{keyword} {indent} {\z@} % - - % FRONT MATTER FONTS - \setattribute{title} {size} {\huge} - \setattribute{author} {size} {\Large} - \setattribute{abstract} {size} {\small\upshape} - \setattribute{keywordname}{size} {\itshape} - \setattribute{thebibliography}{size}{\footnotesize} - - \def\put@fmt@data{% - \copyright@fmt% - \@thanks% - \history@fmt - \fline@cmd% - \abstract@fmt% - \keyword@fmt% - \lline@cmd% - \tableofcontents@fmt} - - \setattribute{keyword}{KWD}{Keywords:} - \setattribute{email}{text}{E-mail: } - - \def\theaddressref{\alph{addressref}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the BJPS journal layout: - -\if@bjpslayout - - \setattribute{keyword}{AMS}{AMS 2000 subject classifications.} - \setattribute{keyword}{KWD}{Keywords and phrases.} - - \setattribute{abstractname}{skip} {.\enskip} - - \setattribute{title} {size} {\Large\bfseries\mathversion{bold}} - \setattribute{address} {size} {\scriptsize} - \setattribute{keywordname}{size} {\itshape} - \setattribute{runninghead}{size} {\footnotesize} - \setattribute{pagenumber} {size} {\small} - \setattribute{thebibliography}{size}{\footnotesize} - - \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% - \@ifnonempty{\@volume\@pubyear\@pagerange\break}% - \@ifnonempty{\journal@issn\break}% - \doi@text}% - - \setattribute{email} {text}{E-mail: } - \setattribute{url} {text}{URL: } - \setattribute{fullurl}{text}{URL: } - - \def\thethanks{\@arabic\c@thanks} - \def\theaddressref{\alph{addressref}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% smart \MR -%% code suggested by Vilmos Prokaj -%% solves the problem when MR is in a format -%% \MR{MR1037262 (91i:60148)} - -% without MR this macro removes the MR prefix if it -% is present unchange the argument otherwise -\def\woMR#1{\w@MR#1MR#1MR\relax}% -\def\w@MR#1MR#2MR#3\relax{#2} - -% this splits MR... (...) -\def\@MR#1 #2\relax#3{% - \href{http://www.ams.org/mathscinet-getitem?mr=#1}% - {\MRfixed{#3}}}% - -\def\MRfixed{MR\woMR}% - -\let\MR\MRfixed - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% interaction with hyperref - -\def\test@hyperref{\@ifundefined{Hy@SetCatcodes}{}{\imsart@hyperref@settings}} - -\AtBeginDocument{\test@hyperref} - -\def\imsart@hyperref@settings{% -% -% hooks for the \thanksref, \thankstext: - \def\thankref@hyperlink##1{% - \edef\@tempx{##1thanks}% - \hbox{\hyperlink{##1}{\saferef{\@tempx}}}} - \def\thanks@hypertarget##1{\smash{\raise\baselineskip\hbox{\protect\hypertarget{##1}{}}}} -% redefine pagenumbering - \let\pagenumbering\ims@pagenumbering -% activate href - \let\ims@href\href% - \let\safe@phantomsection\phantomsection -% put document info - \def\write@pdfinfo##1##2{\protected@write\@auxout{\no@harm}{\string\gdef\string##1{##2}}} - \@ifundefined{hy@title}{}{\pdfstringdef\@pdftitle{\hy@title}} - \@ifundefined{hy@author}{}{\pdfstringdef\@pdfauthor{\hy@author}} - \@ifundefined{hy@subject}{}{\pdfstringdef\@pdfsubject{\hy@subject}} - \@ifundefined{hy@keywords}{}{\pdfstringdef\@pdfkeywords{\hy@keywords}} -% - \@ifundefined{user@hy@title}{}{\global\let\@pdftitle\user@hy@title} - \@ifundefined{user@hy@author}{}{\global\let\@pdfauthor\user@hy@author} - \@ifundefined{user@hy@subject}{}{\global\let\@pdfsubject\user@hy@subject} - \@ifundefined{user@hy@keywords}{}{\global\let\@pdfkeywords\user@hy@keywords} -% -% MathSciNet: -% \def\MR##1{\href{http://www.ams.org/mathscinet-getitem?mr=##1}{MR##1}} - - %% MR with hyperef - \def\MR##1{\@MR##1 \relax{##1}}% - - -% \@ifundefined{Hy@SetCatcodes}{\let\MR\MRfixed}{\relax}% - -} - -\def\write@pdfinfo#1#2{} - -\newtoks\authors@list -\def\addto@authors@list#1{% - \begingroup% - \no@harm% - \xdef\@act{\global\noexpand\authors@list{\the\authors@list#1}}\@act% - \endgroup} - -\newtoks\keywords@list -\def\addto@keywords@list#1{% - \begingroup% - \no@harm% - \xdef\@act{\global\noexpand\keywords@list{\the\keywords@list#1}}\@act% - \endgroup} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION, SUBSECTION ETC. -% we do not like article appearance: - -\renewcommand\section{\@startsection {section}{1}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\raggedright\bfseries\mathversion{bold}}} - -\renewcommand\subsection{\@startsection {subsection}{2}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\raggedright\bfseries\itshape\mathversion{bold}}} - -\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\raggedright\itshape}} - -\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% - {\medskipamount}% - {-1em}% - {\bfseries}} - -\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% - {\medskipamount}% - {-1em}% - {\itshape}} - - -% Format for the counter: -\def\section@numbersep{.} -\def\subsection@numbersep{.} -\def\subsubsection@numbersep{.} -\def\paragraph@numbersep{.} -\def\subparagraph@numbersep{.} - -\def\@seccntformat#1{{\csname #1@prefix\endcsname\csname the#1\endcsname\csname#1@numbersep\endcsname\enspace}} - - -\let\specialsection\section - -\@namedef{specialsection*}{\section*} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: bjpslayout - -\if@bjpslayout - - \renewcommand\section{\@startsection {section}{1}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\large\bfseries\mathversion{bold}\raggedright}} - - \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% - {-\medskipamount}% - {\smallskipamount}% - {\bfseries\mathversion{bold}\raggedright}} - - \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% - {\medskipamount}% - {-10pt}% - {\normalsize\itshape}} - - \def\subsubsection@prefix{\upshape} - - \def\section@numbersep{} - \def\subsection@numbersep{} - \def\subsubsection@numbersep{} - \def\paragraph@numbersep{} - \def\subparagraph@numbersep{} -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: IMS layout - -\if@imslayout - \renewcommand\section{\@startsection {section}{1}{\parindent}% - {\medskipamount}% - {-10pt}% - {\normalsize\upshape\bfseries\mathversion{bold}}} - - \renewcommand\subsection{\@startsection {subsection}{2}{\parindent}% - {\medskipamount}% - {-10pt}% - {\subsection@shape}} - \def\subsection@shape{\normalsize\itshape} - \def\subsection@prefix{\upshape} - - \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\parindent}% - {\medskipamount}% - {-10pt}% - {\normalsize\itshape}} - \def\subsubsection@prefix{\upshape} - - \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% - {\smallskipamount}% - {-1em}% - {\normalsize\itshape}} - \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% - {0.1pt}% - {-1em}% - {\normalsize\itshape}} - -% must be used for the appendix \section and \thebibliography - \renewcommand\specialsection{\@startsection {section}{1}{\z@}% - {\medskipamount}% - {\smallskipamount}% - {\normalsize\centering\MakeUppercase}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: STS layout - -\if@stslayout - - \def\sec@raggedright{% - \def\\{\hfill\break}\@rightskip\@flushglue \rightskip\@rightskip - \leftskip\z@skip - \parindent\z@} - -% last line will centered to page width - - \def\fl@hangfrom#1{\noindent {#1}} - \def\TO@fl{\let\@hangfrom\fl@hangfrom} - - - \renewcommand\section{\@startsection {section}{1}{\z@}% - {\medskipamount}% - {\smallskipamount}% - {\centering\TO@fl\normalsize\sffamily\fontseries{bx}\selectfont\mathversion{bold}\MakeUppercase}} - - \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% - {\smallskipamount}% - {\smallskipamount}% - {\normalsize\sffamily\fontseries{bx}\selectfont\mathversion{bold}\sec@raggedright}} - - \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\parindent}% - {\smallskipamount}% - {-.5em}% - {\normalsize\itshape}} - - \renewcommand\paragraph{\@startsection{paragraph}{4}{\parindent}% - {\z@}% - {-4pt}% - {\normalsize\itshape}} - - \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% - {0.1pt}% - {-1em}% - {\normalsize\itshape}} - -% must be used for the \thebibliography - \renewcommand\specialsection{\@startsection {section}{1}{\z@}% - {\bigskipamount}% - {\smallskipamount}% - {\normalsize\centering\MakeUppercase}} - -% Format for the counter: - \def\section@numbersep{.} - \def\subsection@numbersep{} - \def\subsubsection@numbersep{} - \def\paragraph@numbersep{} - \def\subparagraph@numbersep{} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: BJ layout - -\if@bjlayout - - \renewcommand\section{\@startsection {section}{1}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\Large\bfseries\mathversion{bold}\raggedright}} - - \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% - {-\bigskipamount}% - {\medskipamount}% - {\large\bfseries\mathversion{bold}\raggedright}} - - \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% - {-\medskipamount}% - {\smallskipamount}% - {\itshape\raggedright}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: AIHP layout - -\if@aihplayout - - \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% - {-\medskipamount}% - {\medskipamount}% - {\itshape\raggedright}} - - \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% - {-\medskipamount}% - {.01\p@}% - {\itshape\raggedright}} - - \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% - {\medskipamount}% - {-10pt}% - {\itshape}} - - \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% - {0.1pt}% - {-1em}% - {\itshape}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \thanksref will not print "??" if label is undefined - -\if@noundefthanksref - - \AtBeginDocument{\let\sv@thankref@hyperlink\thankref@hyperlink}% - - \def\thanksref@hook{% - \@ifundefined{r@\@tempb thanks}{% - \let\thankref@hyperlink\@gobble% - \let\@tempa\@empty}% - {\let\thankref@hyperlink\sv@thankref@hyperlink}% - } - -\fi -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% loading of amsmath - -\def\set@amsthm{ - \def\ims@thmshape{0} - \if@imslayout \def\ims@thmshape{1}\fi - \if@stslayout \def\ims@thmshape{1}\fi - \if@bjlayout \def\ims@thmshape{2}\fi - \if@aihplayout \def\ims@thmshape{3}\fi - \if@bjpslayout \def\ims@thmshape{3}\fi - - \ifcase\ims@thmshape - \or %1 - \thm@notefont{\upshape} - \newtheoremstyle{plain} {\medskipamount}{\medskipamount}{\itshape}{\parindent}{\scshape}{.}{1em}{} - \newtheoremstyle{definition}{\medskipamount}{\medskipamount}{\normalfont}{\parindent}{\scshape}{.}{1em}{} - \newtheoremstyle{remark} {\medskipamount}{\medskipamount}{\normalfont}{\parindent}{\scshape}{.}{1em}{} - - \renewenvironment{proof}[1][\proofname]{\par - \pushQED{\qed}% - \normalfont \topsep\medskipamount% - \trivlist - \labelsep.5em% - \item[\hskip\labelsep\hskip\parindent - \scshape ##1\@addpunct{.}]\ignorespaces - }{% - \popQED\endtrivlist\@endpefalse - } - \or %2 - - \newtheoremstyle{plain} {\medskipamount}{\medskipamount}{\itshape}{\z@}{\bfseries}{.}{1em}{} - \newtheoremstyle{definition}{\medskipamount}{\medskipamount}{\itshape}{\z@}{\bfseries\itshape}{.}{1em}{} - \newtheoremstyle{remark} {\medskipamount}{\medskipamount}{\normalfont}{\z@}{\bfseries\itshape}{.}{1em}{} - - \renewenvironment{proof}[1][\proofname]{\par - \pushQED{\qed}% - \normalfont \topsep\medskipamount\relax - \trivlist - \item[\hskip\labelsep - \itshape\bfseries - ##1\@addpunct{.}]\ignorespaces - }{% - \popQED\endtrivlist\@endpefalse - } - - - \or %3 - - \renewenvironment{proof}[1][\proofname]{\par - \pushQED{\qed}% - \normalfont \topsep\medskipamount\relax - \trivlist - \item[\hskip\labelsep - \bfseries - ##1\@addpunct{.}]\ignorespaces - }{% - \popQED\endtrivlist\@endpefalse - } - - \else - \fi} - - -\if@load@amsmath - \if@amsmath@leqno - \PassOptionsToPackage{leqno}{amsmath} - \fi - \RequirePackage[cmex10]{amsmath} -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% loading of amsthm - -\if@load@amsthm - \RequirePackage{amsthm} - \set@amsthm -\else - \AtBeginDocument{\@ifpackageloaded{amsthm}{\set@amsthm}{}} -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thebibliography, loading natbib - -%%% \citefix -- fixes \NAT@citex (to make a hyperlink from year component in cite command). -\def\citefix{% - \def\NAT@citex% - [##1][##2]##3{% - \NAT@sort@cites{##3}% - \let\@citea\@empty - \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty - \@for\@citeb:=\NAT@cite@list\do - {\edef\@citeb{\expandafter\@firstofone\@citeb}% - \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi - \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea% - {\reset@font\bfseries ?}\NAT@citeundefined - \PackageWarning{natbib}% - {Citation `\@citeb' on page \thepage \space undefined}\def\NAT@date{}}% - {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year - \NAT@parse{\@citeb}% - \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{% - \let\NAT@name=\NAT@all@names - \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}% - \fi - \ifNAT@full\let\NAT@nm\NAT@all@names\else - \let\NAT@nm\NAT@name\fi - \ifNAT@swa\ifcase\NAT@ctype - \if\relax\NAT@date\relax - \@citea\NAT@nmfmt{\NAT@nm}% - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \else - \ifx\NAT@last@nm\NAT@nm\NAT@yrsep - \ifx\NAT@last@yr\NAT@year - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend - \fi - \else - \@citea\NAT@nmfmt{\NAT@nm}% - \NAT@aysep\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \fi - \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \def\@citea{\NAT@sep\ }% - \else\ifcase\NAT@ctype - \if\relax\NAT@date\relax - \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \else - \ifx\NAT@last@nm\NAT@nm\NAT@yrsep - \ifx\NAT@last@yr\NAT@year - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend - \fi - \else - \@citea\NAT@nmfmt{\NAT@nm}% - \ \NAT@@open\if*##1*\else##1\ \fi - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend\fi - \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \if\relax\NAT@date\relax\def\@citea{\NAT@sep\ }% - \else\def\@citea{\NAT@@close\NAT@sep\ }\fi - \fi - }}\ifNAT@swa\else\if*##2*\else\NAT@cmt##2\fi - \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{##1}{##2}}% - \let\@citex\NAT@citex -} - - -\def\set@natbib{% - \if@linksfromyear \citefix \fi - \let\bibfont\thebibliography@size - \setlength\bibsep{0pt}} - -\if@load@natbib - \RequirePackage{natbib} - \set@natbib -\else - \let\xxx@thebibliography\thebibliography - \def\thebibliography{\thebibliography@size\xxx@thebibliography} - \g@addto@macro\@openbib@code{\itemsep\z@} - \AtBeginDocument{\@ifpackageloaded{natbib}{\set@natbib}{}} -\fi - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thebibliography - structured - -%%%%%%%%% Common macros: - -% Setting a "style" for a command: -% \set@bibl@cmd{bvolume} == \def\bvolume#1{{\bvolume@style #1}} - -\def\set@bibl@cmd#1{\expandafter\def\csname #1\endcsname##1{{\csname #1@style\endcsname##1}}} - -\let\endbibitem\relax - -%%%%%%%%% bauthor, beditor - -\def\bbl@bauthor#1{% - \csname bauthor@hook\endcsname% -{% - \let\binits\@firstofone% - \let\bsnm\@firstofone% - \let\bfnm\@gobble% - \let\bparticle\@firstofone% - \let\bsuffix\@firstofone% - \bauthor@style% -#1}} - -\def\bbl@beditor#1{{% - \let\binits\@firstofone% - \let\bsnm\@firstofone% - \let\bfnm\@gobble% - \let\bparticle\@firstofone% - \let\bsuffix\@firstofone% - \beditor@style% -#1}} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bid -% \bid{MR={},doi={},...} - -\define@key{bid}{mr}{\MR{#1}} -\define@key{bid}{doi}{} -\define@key{bid}{pubmed}{} -\define@key{bid}{pii}{} -\define@key{bid}{issn}{} - -\def\bbl@bid#1{% - \setkeys{bid}{#1}% -} - -% for compatibility with old bibtex style -\def\bdoi#1{\ignorespaces} - -%%%%%%%%% common@pub@types - -\def\common@pub@types{% - \def\AND{and }% - \let\betal\@firstofone% - \set@bibl@cmd{btitle}% - \let\byear\@firstofone% - \let\bpages\@firstofone% - \let\bmisc\@firstofone% - \let\bnote\@firstofone% - \let\banumber\@firstofone% - \let\bmrnumber\MR% - \let\bid\bbl@bid% - \set@bibl@cmd{bvolume}% - \csname common@pub@types@hook\endcsname% -} - - -%%%%%%%%% default stiliai - - \setattribute{bauthor}{style}{\scshape} - \setattribute{beditor}{style}{\scshape} - - \setattribute{bjournal} {style}{\itshape} - \setattribute{bbooktitle}{style}{\itshape} - \setattribute{bseries} {style}{\itshape} - - \setattribute{bvolume} {style}{\bfseries} - -%%%%%%%%% barticle - -\def\barticle{\@ifnextchar[{\@barticle}{\@barticle[]}} - -\def\@barticle[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \set@bibl@cmd{bjournal}% -} - -%%%%%%%%% bbook - -\def\bbook{\@ifnextchar[{\@bbook}{\@bbook[]}} - -\def\@bbook[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\beditor\bbl@beditor% - \let\bedition\@firstofone% - \set@bibl@cmd{bseries}% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% -% - \let\btitle@style\itshape% -} - - -%%%%%%%%% bincollection - -\def\bincollection{\@ifnextchar[{\@bincollection}{\@bincollection[]}} - -\def\@bincollection[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\beditor\bbl@beditor% - \set@bibl@cmd{bbooktitle}% - \let\bchapter\@firstofone% - \let\bedition\@firstofone% - \set@bibl@cmd{bseries}% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% - \def\bauthor@hook{\let\beditor@style\relax} -} - -%%%%%%%%% binproceedings - -\def\binproceedings{\@ifnextchar[{\@binproceedings}{\@binproceedings[]}} - -\def\@binproceedings[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\beditor\bbl@beditor% - \set@bibl@cmd{bbooktitle}% - \set@bibl@cmd{bseries}% - \let\borganization\@firstofone% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% -} - -%%%%%%%%% binbook - -\def\binbook{\@ifnextchar[{\@binbook}{\@binbook[]}} - -\def\@binbook[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\beditor\bbl@beditor% - \set@bibl@cmd{bbooktitle}% - \let\bchapter\@firstofone% - \let\bedition\@firstofone% - \set@bibl@cmd{bseries}% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% -% - \let\btitle@style\itshape -} - - -%%%%%%%%% bproceedings - -\def\bproceedings{\@ifnextchar[{\@bproceedings}{\@bproceedings[]}} - -\def\@bproceedings[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\beditor\bbl@beditor% - \let\bedition\@firstofone% - \set@bibl@cmd{bseries}% - \let\bpublisher\@firstofone% - \let\borganization\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% -% - \let\btitle@style\itshape -} - - -%%%%%%%%% btechreport - -\def\btechreport{\@ifnextchar[{\@btechreport}{\@btechreport[]}} - -\def\@btechreport[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\btype\@firstofone% - \let\bnumber\@firstofone% - \let\binstitution\@firstofone% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% -} - -%%%%%%%%% bmanual - -\def\bmanual{\@ifnextchar[{\@bmanual}{\@bmanual[]}} - -\def\@bmanual[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\bedition\@firstofone% - \let\borganization\@firstofone% - \let\bpublisher\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% - \let\bisbn\@gobble% -} - -%%%%%%%%% mastersthesis - -\def\bmastersthesis{\@ifnextchar[{\@bmastersthesis}{\@bmastersthesis[]}} - -\def\@bmastersthesis[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\bschool\@firstofone% - \let\bpublisher\@firstofone% - \let\btype\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% -} - -%%%%%%%%% phdthesis - -\def\bphdthesis{\@ifnextchar[{\@bphdthesis}{\@bphdthesis[]}} - -\def\@bphdthesis[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\bpublisher\@firstofone% - \let\bschool\@firstofone% - \let\btype\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% -} - -%%%%%%%%% bbooklet - -\def\bbooklet{\@ifnextchar[{\@bbooklet}{\@bbooklet[]}} - -\def\@bbooklet[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\bhowpublished\@firstofone% - \let\baddress\@firstofone% - \let\blocation\@firstofone% -} - -%%%%%%%%% bunpublished - -\def\bunpublished{\@ifnextchar[{\@bunpublished}{\@bunpublished[]}} - -\def\@bunpublished[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% -} - -%%%%%%%%% bmisc - -\def\bmisc{\@ifnextchar[{\@bmisc}{\@bmisc[]}} - -\def\@bmisc[#1]{% - \common@pub@types% - \let\bauthor\bbl@bauthor% - \let\bhowpublished\@firstofone% -} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bptok - -\def\bptok#1{\ignorespaces} - -\ifx\OrigBibText\undefined \long\def\OrigBibText#1\endOrigBibText{}\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% appendix - -\if@imslayout - -% appendix mess up everything in this layout: - - \renewcommand\appendix{\par - \def\subsection@shape{\normalsize\upshape\bfseries\mathversion{bold}} - \let\section\specialsection - \def\section{\@ifnextchar*{\@appsectionstar}{\@appsectionnostar}}% - \def\section@prefix{\appendixname\ }% - \def\section@numbersep{:}% - \setcounter{section}{0}% - \setcounter{subsection}{0}% - \gdef\thesection{\@Alph\c@section}} - -% \section*{Appendix} -> APPENDIX - \def\@appsectionstar*#1{% - \specialsection*{#1}% - \setcounter{section}{1}% -% \addcontentsline{toc}{section}{#1} -} - -% \section{} -> APPENDIX A -% \section{proof} -> APPENDIX A: PROOF - \def\@appsectionnostar#1{% - \ifx.#1.% - \def\section@numbersep{}\specialsection[\appendixname\ \thesection]{}% - \else% - \def\section@numbersep{:}\specialsection{#1}% - \fi} - -% dirty trick with \thebibliography - \let\old@thebibliography\thebibliography - \def\thebibliography{\let\section\specialsection\old@thebibliography} - -\else - - \renewcommand\appendix{\par - \let\old@section\section% - \def\section{\@ifnextchar*{\@appsectionstar}{\@appsectionnostar}}% - \def\section@prefix{\appendixname\ }% - \def\section@numbersep{:}% - \setcounter{section}{0}% - \setcounter{subsection}{0}% - \gdef\thesection{\@Alph\c@section}} - - \def\@appsectionstar*#1{% - \old@section*{#1}% - \setcounter{section}{1}% -% \addcontentsline{toc}{section}{#1} -} - - \def\@appsectionnostar#1{% - \ifx.#1.% - \def\section@numbersep{}\old@section[\appendixname\ \thesection]{}% - \else% - \def\section@numbersep{:}\old@section{#1}% - \fi} - - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% supplement -% -%\begin{supplement}[id=suppA] -% \sname{Supplement A} -% \stitle{} -% \slink[doi]{} -% \slink[url]{http://lib.stat.cmu.edu/aoas/???/???} -% \sdatatype{.zip} -% \sfilename{foo.zip} -% \sdescription{} -%\end{supplement} -% \thesuppdoi{suppA} -% \ref{suppA} -% \hyperlink{suppA}{text} - -\def\supplement@name{Supplementary Material} - -\def\sname#1{\def\@sname{#1}\def\@currentlabel{#1}} -\def\stitle#1{\def\@stitle{#1}} -\def\sdatatype#1{\def\@sdatatype{#1}} -\def\sfilename#1{} -\def\slink[#1]#2{\expandafter\def\csname slink@#1\endcsname{#2}} -\def\sdescription#1{\def\@sdescription{#1}} - -\def\suppsection@fmt{\specialsection*{\supplement@name}} - -\def\slink@doi@fmt{% - \url@fmt{doi: }{}{\slink@doi}{\doi@base\slink@doi}% - \@ifundefined{supp@label}{}{% - \expandafter\xdef\csname\supp@label @doi\endcsname{\slink@doi}% - \expandafter\xdef\csname\supp@label @url\endcsname{\doi@base\slink@doi}}% -} - -\def\slink@url@fmt{% - \url@fmt{}{}{\slink@url}{\slink@url}% - \@ifundefined{supp@label}{}{% - \expandafter\xdef\csname\supp@label @url\endcsname{\slink@url}}% -} - -\def\thesuppdoi#1{\@ifundefined{#1@doi}% - {\@latex@error{Undefined supplement id=#1}{??}}% - {\def\@tempx{\csname #1@doi\endcsname}% - \@ifundefined{#1@url}{\def\@tempy{\doi@base\csname #1@url\endcsname}}{\def\@tempy{\csname #1@url\endcsname}}% - \url@fmt{DOI: }{}{\@tempx}{\@tempy}}% -} - -\define@key{supplement}{id}{\def\supp@label{#1}} - -\long\def\supplement{\@ifnextchar[{\@supplement}{\@supplement[]}} - -\long\def\@supplement[#1]{% - \suppsection@fmt% - \global\let\suppsection@fmt\smallskip% - \setkeys{supplement}{#1}% -} - -\def\endsupplement{% - \@ifundefined{@sname}{}{\@ifundefined{supp@label}{}{\hypertarget{\supp@label}{}\label{\supp@label}}\textbf{\@sname: }}% - \@ifundefined{@stitle}{}{\textbf{\@stitle\ }}% -% - \\ - (% - \@ifundefined{slink@doi}{}{\slink@doi@fmt}% - \@ifundefined{slink@url}{}{\slink@url@fmt}% - \@ifundefined{@sdatatype}{}{; \@sdatatype}% - ). - \@ifundefined{@sdescription}{}{\@sdescription}% - \par} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOC in "article" class is a mess: - - -% for hyperref -\def\toclevel@title{0} - -\newcommand*\l@title[2]{} -\newcommand*\l@author[2]{} -\newcommand*\l@doi[2]{} -\newcommand*\l@arxiv[2]{} -\newcommand*\l@jobname[2]{} -\newcommand*\l@begintocitem[2]{} -\newcommand*\l@endtocitem[2]{} - -\newif\if@changetoc \@changetocfalse -\@ifclassloaded{article}{\@changetoctrue}{} - -\if@changetoc - - \@ifundefined{contentsname@cmd}{\def\contentsname@cmd{\section*{\contentsname}}}{} - - \renewcommand\tableofcontents{% - \nocontentsline - \contentsname@cmd% - \@starttoc{toc}% - } - - \renewcommand*\l@section{\@dottedtocline{1}{\z@}{1.5em}} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% number lines - -\ifnumberlines@ - - \long\def\l@addto@macro#1#2{% - \toks@\expandafter{#1#2}% - \edef#1{\the\toks@}} - - \setattribute{numberlines}{size}{\scriptsize\ttfamily} - \setattribute{numberlines}{skip}{24\p@} - - \def\numberlines@hook{% - \l@addto@macro\@evenhead\put@numberlines@box% - \l@addto@macro\@oddhead\put@numberlines@box} - - \g@addto@macro\ps@imsheadings\numberlines@hook - \g@addto@macro\ps@copyright\numberlines@hook - - \newbox\numberlines@box - \newskip\numberlines@box@skip - - \def\set@numberlines@box{% - \setlength\numberlines@box@skip\headsep - \addtolength\numberlines@box@skip{5\p@} - % - \setbox\numberlines@box\vtop to\textheight{% - \parindent\z@ - \vskip\z@ - \@tempcnta=0 - \@tempdima=\z@ - \loop - \advance\@tempcnta by1 - \advance\@tempdima by\baselineskip - \hbox to\textwidth{% - \llap{\numberlines@size\the\@tempcnta\kern\numberlines@skip} - \hfill - \rlap{\numberlines@size\kern\numberlines@skip\the\@tempcnta}} - \ifdim\@tempdima<\textheight\repeat - \vss - }% - % - \ht\numberlines@box\z@ - \dp\numberlines@box\z@ - } - - \def\put@numberlines@box{\lower\numberlines@box@skip\hbox to\z@{\hss\copy\numberlines@box}} - - \AtBeginDocument{\set@numberlines@box} - -\fi - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INICIALIZATION - -% Read local configuration file (if exist): -% imsart.cnf imsart-ps.cnf imsart-lnms.cnf - -\@input{\imsfmt@name\journal@id.cnf} - - -\@twosidetrue -\pagenumbering{arabic} -\frenchspacing -\init@settings -\pagestyle{imsheadings} - -\endinput -%% -%% History: -2014.10.16 - added \qq{} -2014.10.13 - added \OrigBibText and \endOrigBibText -2014.07.30 - removed \raggedright from \relateddois -2014.07.23 - added \relateddoi and \relateddois -2014.02.20 - "Submitted to the Bernoulli" changed to "Submitted to Bernoulli"; -2014.01.08 - "Submitted to the Statistical Science" changed to "Submitted to Statistical Science"; -2013.05.28 - keyword key MSC added (MSC 2010 subject classifications:); -2013.03.06 - added \bpublisher for the \bmanual entry; -2012.08.31 - bug fix in stslayout; -2012.08.16 - added new bibliography commands; -2012.04.10 - bug fix in stslayout; -2010.03.13 - new option linksfromyear (makes a hyperlink only from year component of the cite command); -2012.02.28 - SSY - references layout changed; -2012.02.07 - new option noundefthanksref (SSY journal); -2011.12.06 - empty command \sfilename added; -2011.12.01 - when \title is centered, \\ is defined as \break; -2011.11.28 - bugfix in \title command; - - \thanksref made robust; -2011.11.15 - small fixes related to the webbib tagging; -2011.11.15 - minor change: bug fix when contructing keywords list for pdf's metadata; -2011.05.20 - SS journal url changed; -2011.03.02 - SSY copyright fixed; -2011.01.24 - \bdoi added; -2010.09.07 - journal url changed for EJS journal; -2010.08.03 - \tableofcontents fixed for the imslayout journals; -2010.04.27 - support for the "Stochastic Systems" (ssy) added; -2009.12.16 - \betal added -2009.08.13 - support for the structured bibliography added (imsart-number.bst,imsart-nameyear.bst) - options [numbers,sort&compress] from natbib package removed -2009.05.21 - added new option "bjps" -2009.02.27 - all hyperref links are set to "blue" - - smart \MR command (code suggested by Vilmos Prokaj -2008.08.29 - supplement environment added -2008.01.24 - for "coll" changed journal url -2008.01.09 - added new option "coll" -2007.12.10 - added new option "aihp" - - abstract have an attribute language= - - multiple abstracts - - \atltitle{} - title in another language -2007.09.18 - fixed small error in SS (affiliation) -2007.04.13 - fixed small error in EJS -2007.04.02 - ISSN numbers of EJS and SS included -2007.02.20 - support for the "Electronic Journal of Statistics" (ejs) added; -2007.01.24 - support for the "The Annals of Applied Statistics" (aoas) and Bernoulli (bj) added; -2006.10.13 - small bug with "lnms, ps, ss" options fixed; -2006.09.07 - if no options specified, imsart.sty is loaded with "generic" option; - - new options: imslayout, stslayout -2006.08.23 -"author's addresses" secion added to bookmarks (aap,aop,aos); - -completely new STS layout; - -\tableofcontents adjusted, could be used in frontmatter part; - -support for LNMS Table of Contents; - -support for LNMS "List of Contributors" (\contributor{Author, F.}{University}); - -command \arxiv{math.PR/0000000} introduced to provide link to article location in arXiv - -\@journal{} changed to \journal@name - -\ead{} correctly sets the pdf link when "http://" prefix is used; - -\ead[...,nopdflink]{} supresses pdf link; - -a lot of internal changes; - - fix of a bug with newer hyperref versions (\orig@footnotetext) - -equation numbers are at left for LNMS layout; - -2006.03.07 -command \volumename{} introduced + small changes for LNMS option - (addresses will be positioned on title page) - -pdf document properties could be changed with commands - \pdftitle{}, \pdfsubject{}, \pdfauthor{} - -2006.01.04 support for the "Statistics Surveys" (ss) added; - -2005.10.19 fix of a bug with bibliography and ims layout - \@footnotetext is changed due to the arXiv hyperref setup - -2005.05.19 New options singlespacing, doublespacing, linenumbers, nolinenumbers introduced; - Table and figure captions changed - -%% End of file `imsart.sty'. +%% This is file `imsart.sty' +%% +%% LaTeX 2e style file for the processing of LaTeX2e files +%% of the following IMS/BS journals: +%% +%% The Annals of Probability +%% The Annals of Applied Probability +%% The Annals of Statistics +%% The Annals of Applied Statistics +%% Statistical Science +%% Probability Surveys +%% Statistics Surveys +%% Electronic Journal of Statistics +%% IMS Lecture Notes-Monograph Series +%% IMS Collections +%% Bernoulli +%% Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques +%% Brazilian Journal of Probability and Statistics +%% Stochastic Systems +%% +%% Institute of Mathematical Statistics, U.S.A. +%% Bernoulli Society +%% Institut Henry Poincare +%% Brazilian Statistical Association +%% +%% Macros written by Vytas Statulevicius, VTeX, Lithuania +%% for Institute of Mathematical Statistics, U.S.A. +%% Please submit bugs or your comments to vytas@vtex.lt +%% +%% The original distribution is located at: +%% http://www.e-publications.org/ims/support +%% +%% This style file contains additional macros and is designed to use +%% with standart "article.cls" +%% +%% You are free to use this style file as you see fit, provided +%% that you do not make changes to the file. +%% If you DO make changes, you are required to rename this file. +%% +%% It may be distributed under the terms of the LaTeX Project Public +%% License, as described in lppl.txt in the base LaTeX distribution. +%% Either version 1.0 or, at your option, any later version. +%% +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +%% +%% Bug fixes and changes: at end of file + +% TeX programming: Vytas Statulevicius, VTeX, Lithuania, vytas@vtex.lt +% Requires Latex2e, ver.2000.06 + +\def\imsfmt@name{imsart} +\def\imsfmt@version{2014/10/16} + +\ProvidesFile{imsart.sty} + [\imsfmt@version IMS article style (VS)] + +% hyperref must be loaded after: +\@ifpackageloaded{hyperref}{\@latex@error{Package 'hyperref' must be loaded after 'imsart'!}\@ehc}{} + +% Passoptions to hyperref: + +\PassOptionsToPackage{colorlinks,citecolor=blue,urlcolor=blue,linkcolor=blue,pagecolor=blue,linktocpage=true}{hyperref} + +% General options: + +% Put keywords as footnote +\newif\if@keywordsasfootnote +\DeclareOption{keywordsasfootnote}{\@keywordsasfootnotetrue} + +% Put history as footnote +\newif\if@historyasfootnote +\DeclareOption{historyasfootnote}{\@historyasfootnotetrue} + +% Put address as footnote +\newif\if@addressasfootnote +\DeclareOption{addressasfootnote}{\@addressasfootnotetrue} + +% Put addresses at end of document +\newif\if@addressatend +\DeclareOption{addressatend}{\@addressatendtrue} + +% Put "." after inline section headings: +\newif\if@autosecdot +\DeclareOption{autosecdot} {\@autosecdottrue} +\DeclareOption{noautosecdot}{\AtBeginDocument{\@autosecdotfalse}} + +% do not print thanksref undefined marks +\newif\if@noundefthanksref +\DeclareOption{noundefthanksref}{\@noundefthanksreftrue} + +% Load amsmath style with corerect settings: +\newif\if@load@amsmath +\DeclareOption{amsmath}{\@load@amsmathtrue} + +% Load amsthm style with corerect settings: +\newif\if@load@amsthm +\DeclareOption{amsthm}{\@load@amsthmtrue} + +% Load amsmath with leqno option +\newif\if@amsmath@leqno + +% Load natbib with correct settings: +\newif\if@load@natbib +\DeclareOption{natbib}{\@load@natbibtrue} + +% When hyperref is loaded, makes a hyperlink only from year component of the cite command: +\newif\if@linksfromyear\@linksfromyearfalse +\DeclareOption{linksfromyear}{\@linksfromyeartrue} + +% For LNMS we need to create a TOC of book, so we will +% enable writing to .aux + +\newif\if@supertoc \@supertocfalse + +% Information about journals + +\def\set@generic{\def\@tempa{-generic}\ifx\journal@id\@tempa\let\affiliation\@gobble\fi} + +\DeclareOption{generic}{% + \AtEndOfPackage{\set@generic} + \def\journal@id{-generic}} + +\DeclareOption{ps}{% + \def\journal@id{-ps} + \def\journal@name{Probability Surveys } + \def\journal@issn{ISSN: 1549-5787} + \def\journal@url{http://www.i-journals.org/ps} + \AtEndOfPackage{\let\affiliation\@gobble}} + +% Information about journals +\DeclareOption{ss}{% + \def\journal@id{-ss} + \def\journal@name{Statistics Surveys } + \def\journal@issn{ISSN: 1935-7516} + \def\journal@url{http://projecteuclid.org/ssu} + \AtEndOfPackage{\let\affiliation\@gobble}} + +% Information about journals +\DeclareOption{ejs}{% + \def\journal@id{-ejs} + \def\journal@name{Electronic Journal of Statistics } + \def\journal@issn{ISSN: 1935-7524} + \def\journal@url{http://projecteuclid.org/ejs} + \AtEndOfPackage{\let\affiliation\@gobble}} + +\DeclareOption{lnms}{% + \def\journal@id{-lnms} + \def\journal@name{IMS Lecture Notes--Monograph Series } + \@twosidetrue + \def\copyrightowner@text{Institute of Mathematical Statistics} + \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% + \def\journal@url{http://www.imstat.org/publications/lecnotes.htm} + \set@page@layout{30pc}{610pt}% 30pc * 51 line + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressasfootnotetrue + \@supertoctrue + \AtBeginDocument{% + \setattribute{title} {skip} {28\p@} + \setattribute{keywordname}{size}{\itshape} + } +} + +\DeclareOption{coll}{% + \def\journal@id{-coll} + \def\journal@name{IMS Collections } + \@twosidetrue + \def\copyrightowner@text{Institute of Mathematical Statistics} + \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% + \def\journal@url{http://www.imstat.org/publications/imscollections.htm} + \set@page@layout{30pc}{610pt}% 30pc * 51 line + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressasfootnotetrue + \@supertoctrue + \AtBeginDocument{% + \setattribute{title} {skip} {28\p@} + \setattribute{keywordname}{size}{\itshape} + } +} + + +% Options for the IMS journals: + +\DeclareOption{aap}{% + \def\journal@id{-aap} + \def\journal@name{Submitted to the Annals of Applied Probability } + \def\journal@url{http://www.imstat.org/aap/} + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue +} + +\DeclareOption{aop}{% + \def\journal@id{-aop} + \def\journal@name{Submitted to the Annals of Probability } + \def\journal@url{http://www.imstat.org/aop/} + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue +} + +\DeclareOption{aos}{% + \def\journal@id{-aos} + \def\journal@name{Submitted to the Annals of Statistics } + \def\journal@url{http://www.imstat.org/aos/} + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue +} + +\DeclareOption{aoas}{% + \def\journal@id{-aoas} + \def\journal@name{Submitted to the Annals of Applied Statistics } + \def\journal@url{http://www.imstat.org/aoas/} + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue +} + + +\DeclareOption{sts}{% + \def\journal@id{-sts} + \def\journal@name{Submitted to Statistical Science } + \def\journal@url{http://www.imstat.org/sts/} + \set@page@layout{32pc}{658pt}% 32pc * 55 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@stslayouttrue + \AtBeginDocument{\if@twocolumn\set@page@layout{42pc}{658pt}\fi} +} + +\DeclareOption{bj}{% + \def\journal@id{-bj} + \def\journal@name{Submitted to Bernoulli} + \def\journal@url{http://isi.cbs.nl/bernoulli/} + \set@page@layout{32pc}{526pt}% 32pc * 44 line + \@twosidetrue + \@bjlayouttrue + \AtEndOfPackage{\let\affiliation\@gobble} +} + +\DeclareOption{aihp}{% + \def\journal@id{-aihp} + \def\journal@name{Submitted to the Annales de l'Institut Henri Poincar\'e - Probabilit\'es et Statistiques} + \def\journal@url{http://www.imstat.org/aihp} + \set@page@layout{39pc}{622pt}% 39pc * 52 line + \@twosidetrue + \@aihplayouttrue + \AtEndOfPackage{\let\affiliation\@gobble} +} + +\DeclareOption{bjps}{% + \def\journal@id{-bjps} + \def\journal@name{Submitted to the Brazilian Journal of Probability and Statistics} + \def\journal@url{http://www.redeabe.org.br} + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@bjpslayouttrue +} + + +\DeclareOption{ssy}{% + \def\journal@id{-ssy} + \def\journal@name{Stochastic Systems } + \def\journal@url{http://www.i-journals.org/ssy/} + \def\copyrightowner@text{Institute of Mathematical Statistics} + \def\journal@issn{$\copyright$~\ims@href{http://www.imstat.org}{\copyrightowner@text}, \@copyrightyear}% + \set@page@layout{30pc}{550pt}% 30pc * 46 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue + \@noundefthanksreftrue + \AtEndOfPackage{% + \setattribute{copyright}{text}{% + \url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% + \@ifnonempty{\@pubyear\ \@volume\@issue\@pagerange\break}% + \doi@text\break% + }} + \AtBeginDocument{\def\thebibliography{\let\section\specialsection\old@thebibliography}}% +} + +%% Layouts: +% IMS journals AAP, AOP, AOS has a different layout: + +\newif\if@imslayout \@imslayoutfalse + +\DeclareOption{imslayout}{ + \def\journal@id{-imsgeneric} + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@historyasfootnotetrue + \@keywordsasfootnotetrue + \@addressatendtrue + \@imslayouttrue + \@autosecdottrue} + +% IMS STS journal layout also specific +\newif\if@stslayout \@stslayoutfalse +\DeclareOption{stslayout}{ + \def\journal@id{-stsgeneric} + \set@page@layout{32pc}{658pt}% 32pc * 55 line + \@twosidetrue + \input{leqno.clo}% formula numbers at left + \@amsmath@leqnotrue + \@stslayouttrue + \AtBeginDocument{\if@twocolumn\set@page@layout{42pc}{658pt}\fi}} + +% BS BJ journal layout also specific: +\newif\if@bjlayout \@bjlayoutfalse + +% AIHP journal layout also specific: +\newif\if@aihplayout \@aihplayoutfalse + +% BJPS journal layout also specific: +\newif\if@bjpslayout \@bjpslayoutfalse + +% Spacing +\DeclareOption{doublespacing}{\doublespacing} +\DeclareOption{singlespacing}{\singlespacing} + +\def\singlespacing{\renewcommand{\baselinestretch}{}\large\normalsize} +\def\doublespacing{\renewcommand{\baselinestretch}{1.6}\large\normalsize} + +% Do not print id line at bottom of the page: +\DeclareOption{noinfoline}{\AtBeginDocument{\let\info@line\@empty}} +\DeclareOption{infoline} {\AtBeginDocument{\let\info@line\infoline@text}} + +% Put lines numbers in margins +\newif\ifnumberlines@ \numberlines@false +\DeclareOption{linenumbers}{\numberlines@true} +\DeclareOption{nolinenumbers}{\numberlines@false} + +% Combined options: + +% Use this option for submission for pier review: +\DeclareOption{submission}{% + \singlespacing + \AtBeginDocument{\let\info@line\infoline@text} + \numberlines@false} + +% use this option for pre-publication (preprint): + +\DeclareOption{preprint}{% + \singlespacing + \AtBeginDocument{\let\info@line\@empty} + \numberlines@false} + + + +% Initiate some info: +\def\journal@name{} +\def\journal@url{} +\def\journal@issn{} +\def\journal@id{} +\def\paper@url{} +\def\info@line{} +\def\copyrightowner@text{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set@page@layout + +% \set@page@layout{\textwidth}{\textheight} + +\def\set@page@layout#1#2{% +% + \setlength\textwidth{#1} + \@settopoint\textwidth + \setlength\textheight{#2} + \@settopoint\textheight +% +% make side margins equal: + \setlength\@tempdima {\paperwidth} + \addtolength\@tempdima {-\textwidth} + \setlength\oddsidemargin {.5\@tempdima} + \addtolength\oddsidemargin {-1in} + \setlength\evensidemargin {\oddsidemargin} + \@settopoint\oddsidemargin + \@settopoint\evensidemargin +% +% topmargin + \setlength\topmargin{\paperheight} + \addtolength\topmargin{-2in} + \addtolength\topmargin{-\headheight} + \addtolength\topmargin{-\headsep} + \addtolength\topmargin{-\textheight} + \addtolength\topmargin{-\footskip} % this might be wrong! + \addtolength\topmargin{-.5\topmargin} + \@settopoint\topmargin +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Load imsart.cnf with additional options: +\@input{\imsfmt@name.cnf} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Execute options + +\ExecuteOptions{generic,infoline} +\ProcessOptions + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dimensions + +\setlength\parindent {12\p@} +\setlength\headsep {14\p@} +\setlength\footskip {14\p@} + +\setlength\smallskipamount{6\p@ \@plus 1\p@ \@minus 1\p@} +\setlength\medskipamount {12\p@ \@plus 3\p@ \@minus 3\p@} +\setlength\bigskipamount {18\p@ \@plus 3\p@ \@minus 3\p@} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% setattribute, getattribute, do@option@list + +\def\setattribute{\@ifnextchar[\@setattribute{\@setattribute[]}} +\def\@setattribute[#1]#2#3#4{\expandafter\gdef\csname #2@#3\endcsname{#4}} +\def\getattribute#1#2{\csname #1@#2\endcsname} +\def\sep@key@value#1=#2/?/#3{\setattribute{#3}{#1}{#2}} +\def\do@option@list#1#2{% + \@for\curr@option:={#2}\do{% + \expandafter\sep@key@value\curr@option/?/{#1}\relax + }% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% newpseudoenvironment +% same as \newenvironment, but new environment do not have additional groups \bgroup \egroup +% (i.e. all definitions are not local + +\let\org@begin\begin +\let\org@end\end +\def\begin#1{% + \@ifundefined{pseudo@#1}% + {\org@begin{#1}}{\csname pseudo@#1\endcsname[0]\relax}% + } +\def\end#1{% + \@ifundefined{pseudo@#1}% + {\org@end{#1}}{\csname pseudo@#1\endcsname[1]\relax}% + } +\def\newpseudoenvironment#1#2#3{% + \expandafter\gdef\csname pseudo@#1\endcsname[##1]{% + \relax\ifcase##1\relax\def\@@next@@{#2}\or\def\@@next@@{#3}\else\let\@@next@@\relax\fi\@@next@@}% + } + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pubyear, volume, paperno + +\def\pubyear#1{\gdef\@pubyear{(#1) }\gdef\@copyrightyear{#1 }} + \def\@pubyear{} + \def\@copyrightyear{} + +\def\volumetitle#1{\gdef\volume@title{#1 }} + +\def\volume#1{\gdef\@volume{Vol. #1 }} + \gdef\@volume{} + +\def\issue#1{\gdef\@issue{No. #1 }} + \gdef\@issue{} + +\def\paperno#1{\gdef\@paperno{Paper no. #1 }} + \gdef\@paperno{00} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% firstpage, lastpage, pagerange + +\newcounter{firstpage} +\newcounter{lastpage} + +\def\firstpage#1{\def\@tempa{#1}\ifx\@tempa\@empty\else + \global\c@firstpage=#1 + \global\c@lastpage=#1 + \global\c@page=#1 \ignorespaces\fi} + +\def\lastpage#1{\def\@tempa{#1}\ifx\@tempa\@empty\else + \global\c@lastpage=#1 + \ignorespaces\fi} + +\def\pagerange@sep{--} + +\def\set@pagerange{% + \ifnum\c@firstpage=0% + \else% + \ifnum\c@firstpage=\c@lastpage% + \gdef\@pagerange{\thefirstpage}% + \else% + \gdef\@pagerange{\thefirstpage\pagerange@sep\thelastpage}% + \fi% + \fi} + +\def\@pagerange{} + +\def\pagenumbering#1{% + \gdef\thefirstpage{\csname @#1\endcsname\c@firstpage}% + \gdef\thelastpage{\csname @#1\endcsname\c@lastpage}% + \gdef\thepage{\csname @#1\endcsname\c@page}% +} + +% hyperref redefines \pagenumbering, so we must override hyperref definition: +\let\ims@pagenumbering\pagenumbering + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% startlocaldefs, endlocaldefs + +\def\startlocaldefs{\makeatletter} +\def\endlocaldefs{\makeatother} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thanksref, thanksmark, thankslabel, thankstext +% to be safe with hyperref we will use original LaTeX definitions: +% + +\def\saferef#1{\expandafter\safe@setref\csname r@#1\endcsname\@firstoftwo{#1}} +\let\safe@setref\@setref + +\def\safelabel#1{\@bsphack + \protected@write\@auxout{}% + {\string\thanksnewlabel{#1}{{\@currentlabel}{\thepage}}}% + \@esphack} + +\long\def\safe@footnotetext#1{\insert\footins{% + \reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \splittopskip\footnotesep + \splitmaxdepth \dp\strutbox \floatingpenalty \@MM + \hsize\columnwidth \@parboxrestore + \color@begingroup + \def\@thefnmark{}% + \@makefntext{% + \rule\z@\footnotesep\ignorespaces #1\@finalstrut\strutbox}% + \color@endgroup}}% + + +\long\def\orig@footnotetext#1{\insert\footins{% + \reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \splittopskip\footnotesep + \splitmaxdepth \dp\strutbox \floatingpenalty \@MM + \hsize\columnwidth \@parboxrestore + \protected@edef\@currentlabel{% + \csname p@footnote\endcsname\@thefnmark + }% + \color@begingroup + \@makefntext{% + \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}% + \color@endgroup}}% + + + +\let\thanksnewlabel\newlabel + +% we want to use various counters: +\def\usethankscounter#1{% + \@ifundefined{current@thankscounter}{\gdef\previous@thankscounter{#1}}{\xdef\previous@thankscounter{\current@thankscounter}}% + \def\current@thankscounter{#1}} + +\def\restorethankscounter{\xdef\current@thankscounter{\previous@thankscounter}} + +\newcounter{thanks} +\def\thethanks{\@fnsymbol\c@thanks} +\usethankscounter{thanks} + +% address ref: +\newcounter{addressref} +\def\theaddressref{\arabic{addressref}} + + +%\def\thanksmark@fmt#1{\hbox{$^{#1}$}} +\def\thanksmark@fmt#1{\@textsuperscript{\normalfont#1}} +\def\thanksref@sep{,} + +% hooks for the hyperref: +\def\thankref@hyperlink#1{\saferef{#1thanks}} +\def\thanks@hypertarget#1{} + +% Isvedame zymes +\DeclareRobustCommand{\thanksref}{\@ifnextchar[{\@tempswatrue\@thanksref}{\@tempswafalse\@thanksref[]}} + +\def\@thanksref[#1]#2{% + \if@tempswa% [] + \thanksmark@fmt{#1}% + \else% + \let\@tempa\@empty% + \thanksmark@fmt{\@for\@tempb:=#2\do{% + \csname thanksref@hook\endcsname% + \@tempa\let\@tempa\thanksref@sep% + \edef\@tempb{\expandafter\@firstofone\@tempb\@empty}% + \thankref@hyperlink{\@tempb}}}% + \fi} + +% Suformuojame ir isvedame zyme +\def\thanksmark{\@ifnextchar[{\@tempswatrue\@thanksmark}{\@tempswafalse\@thanksmark[]}} + +\def\@thanksmark[#1]#2{% + \@thankslabel[#1]{#2}% + \safelabel{#2thanks}% + \thanksmark@fmt{\expandafter\saferef{#2thanks}\thanks@hypertarget{#2}}} + +% Suformuojame tik zyme +\def\thankslabel{\@ifnextchar[{\@tempswatrue\@thankslabel}{\@tempswafalse\@thankslabel[]}} + +\def\@thankslabel[#1]#2{% + \if@tempswa% [] + \protected@edef\@currentlabel{#1}% + \else% + \refstepcounter{\current@thankscounter}% + \fi% + \safelabel{#2thanks}}% + +% Suformuojame zyme ir idedame teksta i \@thanks: +\def\thankstext{\@ifnextchar[{\@tempswatrue\@thankstext}{\@tempswafalse\@thankstext[]}} + +\def\@thankstext[#1]#2#3{% + \@thankslabel[#1]{#2}% + \protected@xdef\@thanks{\@thanks\protect\thanks@thefnmark{#2thanks}% + \protect\orig@footnotetext{\thanks@hypertarget{#2}#3}}}% + +\def\thanks@thefnmark#1{\begingroup\unrestored@protected@xdef\@thefnmark{\saferef{#1}}\endgroup}% + + + +% ST makrosas savo numeracijos sistemos sukurimui +\def\setvaluelist#1#2{\@tempcnta=0\relax + \@for\@curr@val:=#2\do{% + \advance\@tempcnta by1\relax + \expandafter\protected@xdef\csname #1@item@\the\@tempcnta\endcsname{\@curr@val}% + }% + \expandafter\protected@xdef\csname #1@item@0\endcsname{\the\@tempcnta}% +} +\xdef\getitemvalue#1#2{\noexpand\csname #1@item@#2\endcsname} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ead, \printead + +\RequirePackage{keyval} + +\def\email@text{e-mail: } +\def\url@text{url: } +\def\fullurl@text{url: } +\def\ead@sep{;~} +\let\ead@size\relax +\def\printead@fmt#1{#1} + +% for BJ journal: +\newcounter{emailref} +\setvaluelist{emailmarks}{*,**,\textdagger,\textdaggerdbl} +\def\theemailref{\getitemvalue{emailmarks}{\the\c@emailref}} +\define@key{ead}{mark}[true]{\usethankscounter{emailref}\thankslabel{\ead@label}} + + +% naudojame keyval paketa +\define@key{ead}{email}[true]{\def\ead@type{email}} +\define@key{ead}{url}[true]{\def\@tempa{fullurl}\ifx\ead@type\@tempa\else\def\ead@type{url}\fi} +\define@key{ead}{label}{\def\ead@label{#1}} + +\define@key{ead}{text}{% + \bgroup% + \def\\{\string\break} + \def\break{\string\break}% + \protected@edef\@currentlabel{#1}% + \safelabel{\ead@label @\ead@type text}% + \egroup} + +\define@key{ead}{nopdflink}[true]{% + \protected@edef\@currentlabel{nolink}% + \safelabel{\ead@label @nopdflink}} + + +\DeclareRobustCommand\ead[2][label= ,email]{{% + \def\ead@type{email}% default + \checkead@prefix#2://\end% + \def\texttildelow{\noexpand\texttildelow}% + \setkeys{ead}{#1}% + \protected@edef\@currentlabel{#2}% + \safelabel{\ead@label @\ead@type}}} + +\def\checkead@prefix#1://#2\end{\ifx.#2.\else\def\ead@type{fullurl}\fi} + +\newif\ifnot@ead@star +\newif\if@printead@opt + +\DeclareRobustCommand{\printead}{\@ifstar{\not@ead@starfalse\@printead}{\not@ead@startrue\@printead}} + +\def\@printead{\@ifnextchar[{\@printead@opttrue\@@printead}{\@printead@optfalse\@@printead[]}} + +\def\@@printead[#1]#2{{% + \if@printead@opt%[] + \def\ims@href@text{#1}% + \not@ead@starfalse% + \fi% + \let\prev@ead@text\relax% + \let\@ead@sep\relax% + \let\ead@text\relax% + \let\ead@prefix\relax% + \def\ead@type{}% + \@tempcnta=0% + \let\sv@ims@href\ims@href% + \printead@fmt{\@for\ead@ref:=#2\do{% + \advance\@tempcnta by1% + \let\ims@href\sv@ims@href% + \@ead@sep\let\@ead@sep\ead@sep% + \@ifundefined{r@\ead@ref @nopdflink}{}{\def\ims@href##1##2{##2}}% + \@ifundefined{r@\ead@ref @email}{}{\let\ead@text\email@text\def\ead@type{email}\def\ead@prefix{mailto:}}% + \@ifundefined{r@\ead@ref @url}{}{\let\ead@text\url@text\def\ead@type{url}\def\ead@prefix{http://}}% + \@ifundefined{r@\ead@ref @fullurl}{}{\let\ead@text\fullurl@text\def\ead@type{fullurl}\def\ead@prefix{}}% + \ifx\prev@ead@text\ead@text\let\ead@text\relax\fi% + \if@printead@opt\ifnum\@tempcnta>1\@latex@error{Command \@backslashchar printead[]{e1} could have only one parameter "e1"!}\@eha\fi% + \else\@ifundefined{r@\ead@ref @\ead@type text}{\def\ims@href@text{\@ifundefined{r@\ead@ref thanks}{}{\thanksref{\ead@ref}}\saferef{\ead@ref @\ead@type}}}{\def\ims@href@text{\@ifundefined{r@\ead@ref thanks}{}{\thanksref{\ead@ref}}\saferef{\ead@ref @\ead@type text}}}\fi% + \ifnot@ead@star\ead@text\fi{\ead@size\def\null{}\ims@href{\ead@prefix\saferef{\ead@ref @\ead@type}}{\ims@href@text}}% + \@ifundefined{ead@text}{}{\let\prev@ead@text\ead@text}}}% +}} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \copyrightowner, \corref + +\def\copyrightowner#1{\def\copyrightowner@text{#1}} + + +% for corresponding author +\def\corref#1{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% normaltext, nohyphen, today + +% normalus tekstas (justify) +\def\normaltext{\let\\=\@normalcr% + \leftskip\z@ \@rightskip\z@ \rightskip\@rightskip% + \parfillskip\@flushglue} + +% skiemenavimo isjungimas +\def\nohyphen{\pretolerance=\@M \tolerance=\@M \hyphenpenalty=\@M \exhyphenpenalty=\@M} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \@ifemptyhbox + +\def\@ifnonempty#1{% + \setbox\@tempboxa\hbox{\ignorespaces #1}% + \ifdim\wd\@tempboxa>1pt #1\fi} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\pagestyle{imsheadings} \thispagestyle{copyright} + + +\if@twoside + +\def\ps@imsheadings{% + \def\@oddfoot{\hfill\info@line}% + \let\@evenfoot\@oddfoot% + \def\@evenhead{\runninghead@size\rlap{\pagenumber@size\thepage}\evenhead@fmt{\leftmark}}% + \def\@oddhead{\runninghead@size\oddhead@fmt{\rightmark}\llap{\pagenumber@size\thepage}}} +\else +\def\ps@imsheadings{% + \def\@oddfoot{\hfill\info@line}% + \let\@evenfoot\@oddfoot% + \def\@evenhead{\runninghead@size\hfill\leftmark/\rightmark\hfill\llap{\pagenumber@size\thepage}}% + \def\@oddhead{\runninghead@size\hfill\leftmark/\rightmark\hfill\llap{\pagenumber@size\thepage}}} +\fi + +\def\ps@copyright{\let\@mkboth\@gobbletwo% + \def\@evenhead{\parbox[t]{\textwidth}{\copyright@size\copyright@text}}% + \let\@oddhead\@evenhead% + \def\@oddfoot{\hfill\pagenumber@size\thepage\hfill\llap{\info@line}}% + \let\@evenfoot\@oddfoot} + +\def\evenhead@fmt#1{\hfill#1\hfill} +\def\oddhead@fmt#1{\hfill#1\hfill} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% url@fmt + + +\def\journalurl#1{\def\journal@url{#1}} +\def\paperurl#1{\def\paper@url{#1}} + +% DOI + +\def\doi#1{% + \gdef\@doi{#1}% + \gdef\doi@text{\url@fmt{DOI: }{\ttfamily}{#1}{\doi@base\@doi}}% +} + +\let\@doi\relax + +\def\doi@base{http://dx.doi.org/} + +\protected\def\relateddoi{\@ifnextchar[{\@tempswatrue\@relateddoi}{\@tempswafalse\@relateddoi[]}} +\def\@relateddoi[#1]#2#3{\protect\ims@href{\doi@base#3}{#3}}% + +\protected\def\relateddois{\@ifnextchar[{\@tempswatrue\@relateddois}{\@tempswafalse\@relateddois[]}} +\def\@relateddois[#1]#2#3{% + \@thankslabel[#1]{#2}% + \bgroup% + \protected@xdef\@thanks{\@thanks\protect\thanks@thefnmark{#2thanks}% + \protect\@footnotetext{\thanks@hypertarget{#2}#3}}% + \egroup% +}% + +% arXiv + + +\def\arxiv#1{% + \gdef\@arxiv{#1}% + \gdef\doi@text{\url@fmt{arXiv: }{\ttfamily}{#1}{\arxiv@base\@arxiv}}% +} + +\let\@arxiv\relax + +% http://arxiv.org/abs/math.PR/0603300 + +\def\arxiv@base{http://arxiv.org/abs/} + + +% {url}{text} +\def\ims@href#1#2{#2} + +% {prefix}{font}{text}{url} + +\def\url@fmt#1#2#3#4{% + \edef\@tempa{#3}% + \ifx\@tempa\@empty% + \else% + #1{#2\ims@href{#4}{#3}}% + \fi} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LIST ENVIRONMENTS + +\parsep\z@ +\topsep\smallskipamount +\partopsep\z@ +\itemsep\z@ +\labelsep.5em + +\def\@listI{\leftmargin\leftmargini + \parsep\z@ + \topsep\smallskipamount + \itemsep\z@} + +\def\list@parindent{1pc} + +% quotation +\let\quotation@size\footnotesize +\def\quotation@itemindent{\list@parindent} +\def\quotation@parindent{\list@parindent} +\def\quotation@leftmargin{\list@parindent} +\let\quotation@rightmargin\z@ +\let\quotation@topsep\smallskipamount + +\def\quotation{% + \list{}{\quotation@size% + \listparindent\quotation@parindent% + \itemindent \quotation@itemindent% + \rightmargin\quotation@rightmargin \leftmargin\quotation@leftmargin% + \partopsep\z@ \topsep\quotation@topsep \parsep\z@% + }% + \item[\Q@strut]\relax} + +\def\endquotation{\endlist} + +\def\Q@strut{\leavevmode\hbox{\vrule height9pt depth1pt width0pt}} + +% quote +\let\quote@size\footnotesize +\def\quote@indent{\z@} +\def\quote@leftmargin{2pc} +\def\quote@rightmargin{2pc} +\let\quote@topsep\smallskipamount + +\def\quote{% + \list{}{\quote@size% + \listparindent\quote@indent% + \itemindent \listparindent% + \rightmargin\quote@rightmargin \leftmargin\quote@leftmargin% + \partopsep\z@ \topsep\quote@topsep \parsep\z@% + }% + \item\relax} + +\def\endquote{\endlist} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% table, figure + +\def\fnum@table{\tablename~\thetable} +\setlength\belowcaptionskip{4\p@} + +\renewenvironment{table} + {\let\@makecaption\@maketablecaption\@float{table}} + {\end@float} +\renewenvironment{table*} + {\let\@makecaption\@maketablecaption\@dblfloat{table}} + {\end@dblfloat} + +\long\def\@maketablecaption#1#2{% + \tablecaption@shape\tablecaption@size% + {\tablename@size #1}\tablename@skip #2\par + \vskip\belowcaptionskip} + +\setattribute{tablecaption}{shape}{\centering} +\setattribute{tablecaption}{size} {\footnotesize\itshape} +\setattribute{tablename} {size} {\scshape} +\setattribute{tablename} {skip} {\endgraf} + + +% figure : use \@makecaption: +\renewcommand\figurename{Fig} + +\long\def\@makecaption#1#2{% + \vskip\abovecaptionskip + \footnotesize + \sbox\@tempboxa{\itshape\textsc{#1}. #2}% + \ifdim \wd\@tempboxa >\hsize + \itshape\textsc{#1}. #2\par + \else + \global \@minipagefalse + \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% + \fi + \vskip\belowcaptionskip} + +\long\def\@makecaption#1#2{% + \vskip\abovecaptionskip + \figurecaption@size + \sbox\@tempboxa{{\figurename@size #1}\figurename@skip #2}% + \ifdim \wd\@tempboxa >\hsize + {\figurename@size #1}\figurename@skip #2\par + \else + \global \@minipagefalse + \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% + \fi + \vskip\belowcaptionskip} + +\setattribute{figurecaption}{size}{\footnotesize\itshape} +\setattribute{figurename} {size}{\scshape} +\setattribute{figurename} {skip}{.~} + + +\def\@floatboxreset{% + \reset@font + \@setminipage + \singlespacing + \footnotesize + \centering +} + +\if@aihplayout + \setattribute{tablecaption}{size} {\footnotesize} + \setattribute{figurecaption}{size}{\footnotesize} +\fi + +\if@bjpslayout + \setattribute{tablename} {size} {\bfseries\upshape} + \setattribute{tablename} {skip} {\enskip} + + \setattribute{figurename} {size}{\bfseries\upshape} + \setattribute{figurename} {skip}{\enskip} + \def\figurename{Figure} +\fi + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FOOTNOTE + +\renewcommand\@makefntext[1]{% + \parindent12pt\@makefnmark #1} + +\def\@makefnmark{\@textsuperscript{\normalfont\@thefnmark}}% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION commands: +% from latex.ltx: +% Two improvements: +% 1. if section command is defined as "inline" the '.' will be inserted after heading; +% 2. section* will write to toc and will appear in pdf bookmarks + +% dirty trick... +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \@tempskipa #4\relax + \@afterindenttrue + \ifdim \@tempskipa <\z@ + \@tempskipa -\@tempskipa \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace\@tempskipa + \fi + \@ifstar + {\def\ssection@level{#2}\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} + +% Trick for the hyperref: +\def\setaftersec@dot#1{\if@autosecdot\setbox0=\hbox{#1}\ifdim\wd0>0\p@\def\aftersec@dot{.}\else\def\aftersec@dot{}\fi\fi} +\let\aftersec@dot\relax + +% section - will add hook for the dot after section heading +\def\@sect#1#2#3#4#5#6[#7]#8{% + \ifnum #2>\c@secnumdepth + \let\@svsec\@empty + \else + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \fi + \@tempskipa #5\relax + \ifdim \@tempskipa>\z@ + \begingroup + #6{% + \@hangfrom{\hskip #3\relax\@svsec}% + \interlinepenalty \@M #8\@@par}% + \endgroup + \csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth \else + \protect\numberline{\csname the#1\endcsname}% + \fi + #7}% + \else + \setaftersec@dot{#8}% + \def\@svsechd{% + #6{\hskip #3\relax + \@svsec #8\aftersec@dot}% + \csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth \else + \protect\numberline{\csname the#1\endcsname}% + \fi + #7}}% + \fi + \@xsect{#5}} + +% section* - will add hook for the dot after section heading and \contentsline +\def\@ssect#1#2#3#4#5{% + \@tempskipa #3\relax + \ifdim \@tempskipa>\z@ + \begingroup + #4{% + \@hangfrom{\hskip #1}% + \interlinepenalty \@M #5\@@par}% + \endgroup + \else + \setaftersec@dot{#5}% + \def\@svsechd{#4{\hskip #1\relax #5\aftersec@dot}}% + \fi + \ifnum\ssection@level=1\phantomsection\addcontentsline{toc}{section}{#5}\fi% + \@xsect{#3}} + +% Block adding to contents for the next command only: +\def\nocontentsline{% + \let\@@addcontentsline\addcontentsline% + \ifx\hyper@anchor\@undefined + \def\addcontentsline##1##2##3{\let\addcontentsline\@@addcontentsline} + \else + \def\addcontentsline##1##2##3##4{\let\addcontentsline\@@addcontentsline} + \fi +} + +\def\qq#1{% + \bgroup% + \ifx.#1.\relax% + \ifmmode% + \mbox{\normalfont\textbf{???}} + \else% + \normalfont\textbf{???}\fi + \else% + \ifmmode% + \mbox{\normalfont\textbf{#1}}% + \else% + \normalfont\textbf{#1}% + \fi% + \fi% + \egroup% +} + +% \phantomsection is defined in hyperref +\let\phantomsection\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER SETTINGS + +% FRONT MATTER FORMATTING PARAMETERS + +\setattribute{frontmatter} {style} {\centering} +\setattribute{title} {style} {\centering\def\\{\break}} +\setattribute{author} {style} {\centering} +\setattribute{address} {style} {\centering} +\setattribute{abstract} {style} {\normaltext} +\setattribute{keyword} {style} {\normaltext} +\setattribute{history} {style} {\normaltext} + +% FRONT MATTER SKIPS +\setattribute{title} {skip} {18\p@} +\setattribute{atltitle} {skip} {14\p@} +\setattribute{authors} {skip} {12pt} +\setattribute{dedicated} {skip} {12\p@} +\setattribute{address} {skip} {6\p@ plus 1\p@ minus 1\p@} +\setattribute{affiliation} {skip} {6\p@ plus 1\p@ minus 1\p@} +\setattribute{abstract} {skip} {10\p@} +\setattribute{abstractname}{skip} {:\enskip} +\setattribute{keyword} {skip} {10\p@} +\setattribute{history} {skip} {10\p@} +\setattribute{frontmatter} {cmd} {\vskip20\p@ plus 3\p@ minus 3\p@ + \@afterindentfalse\@afterheading} +\setattribute{firstpage} {cmd} {} + +% FRONT MATTER DIMENSIONS +\setattribute{abstract} {width} {.8\textwidth} +\setattribute{abstract} {indent} {0\p@} +\setattribute{keyword} {width} {.8\textwidth} +\setattribute{keyword} {indent} {0\p@} % +\setattribute{history} {width} {.8\textwidth} + +% FRONT MATTER FONTS +\setattribute{dochead} {size} {\Large\bfseries} +\setattribute{title} {size} {\LARGE\bfseries} +\setattribute{author} {size} {\normalsize\bfseries} +\setattribute{fnms} {size} {} +\setattribute{snm} {size} {} +\setattribute{address} {size} {\footnotesize\itshape\mdseries} +\setattribute{affiliation}{size} {\footnotesize\itshape\mdseries} +\setattribute{dedicated} {size} {\normalsize\itshape} +\setattribute{ead} {size} {\upshape\ttfamily} +\setattribute{abstract} {size} {\footnotesize\upshape\mdseries} +\setattribute{abstractname}{size} {\bfseries} +\setattribute{keyword} {size} {\footnotesize\upshape\mdseries} +\setattribute{keywordname}{size} {\bfseries} +\setattribute{history} {size} {\footnotesize\mdseries} +\setattribute{copyright} {size} {\footnotesize\raggedright} +\setattribute{runninghead}{size} {\footnotesize\itshape} +\setattribute{pagenumber} {size} {\footnotesize\upshape} +\setattribute{thebibliography}{size}{\normalsize} + +% FRONT MATTER CASE +\setattribute{dochead} {case} {} +\setattribute{title} {case} {} +\setattribute{runninghead}{case} {} + +% TEXT, etc. +\setattribute{doi} {text} {\url@fmt{url: }{\ttfamily}{\paper@url}{\paper@url}} +\setattribute{copyright} {text} {\url@fmt{}{\bfseries}{\journal@name}{\journal@url}\break% + \@ifundefined{volume@title}{}{\textbf{\volume@title}\break}% + \@ifnonempty{\@volume\@pubyear\@pagerange\break}% + \@ifnonempty{\journal@issn\break}% + \doi@text}% + +\setattribute{infoline} {text} {\lower12pt \hbox{\footnotesize\ttfamily\imsfmt@name\journal@id\ ver. \imsfmt@version\ file: \jobname.tex\ date: \today}} +\setattribute{copyright} {owner} {$\copyright$~\@copyrightyear \copyrightowner@text} +\setattribute{author} {prefix} {} +\setattribute{keyword} {postfix} {\unskip.} + +\def\abstractname{Abstract} + +% HISTORY +\setattribute{history} {prefix} {} +\setattribute{history} {postfix} {.} +\setattribute{received} {prefix} {Received~} +\setattribute{received} {postfix} {} +\setattribute{revised} {prefix} {; revised~} +\setattribute{revised} {postfix} {} +\setattribute{accepted} {prefix} {; accepted~} +\setattribute{accepted} {postfix} {} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER STUFF + +% COUNTERS, ETC +\newcounter{author} +\newcounter{address} +\newdimen\sv@mathsurround +\def\author@num{0} + +% RUNNING HEAD +\def\runtitle#1{\gdef\@runtitle{\runninghead@case{#1}}} \def\@runtitle{} +\def\runauthor#1{{\def\etal{et al.}\gdef\@runauthor{\runninghead@case{#1}}}} \def\@runauthor{} + +\newdimen\sv@parindent +\sv@parindent\parindent + +\newbox\fm@box +\newdimen\fm@size + +\let\hy@frontmatter\relax +\let\hy@endfrontmatter\relax +\let\tableofcontents@fmt\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FRONTMATTER + +\def\frontmatter{% + \global\c@author\z@ + \global\c@address\z@ + \renewcommand\thefootnote{\@fnsymbol\c@footnote}% +% + \if@changetoc + \let\old@tableofcontents\tableofcontents% + \def\tableofcontents{\let\tableofcontents@fmt\old@tableofcontents}% + \fi +% + \def\pdftitle##1{\write@pdfinfo{\user@hy@title}{##1}} + \def\pdfauthor##1{\write@pdfinfo{\user@hy@author}{##1}} + \def\pdfsubject##1{\write@pdfinfo{\user@hy@subject}{##1}} + \def\pdfkeywords##1{\write@pdfinfo{\user@hy@keywords}{##1}} +% + \if@supertoc% + \addtocontents{toc}{\protect\contentsline{begintocitem}{}{}{}}% + \addtocontents{toc}{\protect\contentsline{jobname}{\jobname}{}{}} + \ifx\@doi\relax \else\addtocontents{toc}{\protect\contentsline{doi}{\@doi}{}{}}\fi% + \ifx\@arxiv\relax \else\addtocontents{toc}{\protect\contentsline{arxiv}{\@arxiv}{}{}}\fi% + \fi +% + \sv@mathsurround\mathsurround \m@th + \parindent\z@ + \hy@frontmatter + \global\let\maketitle\relax + \open@fm \ignorespaces} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ENDFRONTMATTER + +\def\endfrontmatter{% + \global\@topnum\z@ + \set@pagerange + \markboth{\@runauthor}{\@runtitle}% + \thispagestyle{copyright}% +% + \put@fmt@data% +% + \close@fm +% + \firstpage@cmd +% + \write@pdfinfo{\hy@author}{\the\authors@list} + \write@pdfinfo{\hy@subject}{\journal@name\@copyrightyear\@volume\@issue\@pagerange} + \write@pdfinfo{\hy@keywords}{\the\keywords@list} +% + \if@supertoc% + \addtocontents{toc}{\protect\contentsline{author}{\the\authors@list}{\thepage}{}}% + \addtocontents{toc}{\protect\contentsline{endtocitem}{}{}{}}% + \fi% +% + \write\@mainaux{\string\gdef\string\author@num{\the\c@author}} + \hy@endfrontmatter + \global\mathsurround\sv@mathsurround + \global\c@footnote\z@ + \global\let\@thanks\@empty + \let\title\relax + \let\author\relax + \let\address\relax + \let\frontmatter\relax \let\endfrontmatter\relax + \let\@maketitle\relax \let\@@maketitle\relax + \aftergroup\frontmatter@cmd + } + + +\def\put@fmt@data{% + \copyright@fmt% + \@thanks% + \abstract@fmt% + \keyword@fmt% + \history@fmt + \tableofcontents@fmt} + + +\newdimen\t@xtheight +\def\init@settings{ +\splittopskip=\topskip \splitmaxdepth=\maxdepth +\t@xtheight\textheight \advance\t@xtheight-\splittopskip} + +\def\no@harm{\let\thanks=\@gobble\let\thanksref=\@gobble\let~\space\def\ead[##1]##2{}\let\\=\@empty \def\protect{\noexpand\protect\noexpand}} + +\def\open@fm{% + \global\setbox\fm@box=\vbox\bgroup + \hsize=\textwidth + \frontmatter@style} + +\def\close@fm{% + \par \egroup + \fm@size=\dp\fm@box \advance\fm@size by \ht\fm@box + \@whiledim\fm@size>\t@xtheight \do{% + \global\setbox\@tempboxa=\vsplit\fm@box to \t@xtheight + \unvbox\@tempboxa + \fm@size=\dp\fm@box \advance\fm@size by \ht\fm@box} + \if@twocolumn + \emergencystretch=1pc \twocolumn[\unvbox\fm@box] + \else + \unvbox\fm@box + \fi} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOCHEAD +\def\dochead#1{% + \bgroup + \dochead@size + \leavevmode\vphantom{\strut}\dochead@case{#1}\par + \egroup + \setattribute{title}{skip}{8\p@}} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TITLE +\def\title#1{% + \vglue\title@skip% +% check if we are in {frontmatter} + \def\reserved@a{frontmatter} + \ifx\reserved@a\@currenvir \else \hy@frontmatter\fi + \bgroup% + \no@harm% + \xdef\@argi{#1}% + \xdef\@title{#1}% + \egroup% + \write@pdfinfo{\hy@title}{\@argi} + \if@supertoc% + \addtocontents{toc}{\protect\contentsline{title}{\@argi}{\thepage}{}}% + \fi% + \bgroup% + \title@style\title@size\title@case{#1}\par% + \egroup} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ATLTITLE + +\def\atltitle#1{% + \vglue\atltitle@skip% + \bgroup + \title@size #1\par% + \egroup} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AUTHOR + +% AUG - author block +\def\smart@par{\ifhmode\par\fi} +\newenvironment{aug}{}{\smart@par} + + +\def\and{\unskip~and~} + +\def\author{\@ifnextchar[{\author@fmt}{\author@fmt[]}} + +\def\author@fmt[#1]#2{% + \stepcounter{author}% + \author@fmt@init% + \let\author@fmt@init\relax% + \bgroup% + \def\degs##1{##1}\def\fnms##1{##1}\def\inits##1{##1}\def\snm##1{##1}\def\roles##1{##1}% + \@tempcnta=\author@num\relax% + \ifnum\c@author=\@tempcnta \def\author@sep{ and }\else \def\author@sep{, }\fi% + \ifnum\c@author=1\addto@authors@list{#2}\else\addto@authors@list{\author@sep #2}\fi% + \def\fnms##1{{\fnms@size{##1}}}\def\snm##1{\snm@size{##1}}% + \noindent#2\thanksref{#1}% + \egroup} + +\def\author@fmt@init{% + \vskip\authors@skip% + \noindent\leavevmode\author@style\author@size\author@prefix } + +\let\author@fmt@init@def\author@fmt@init + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEDICATED +\def\dedicated#1{% + \vskip\dedicated@skip + \bgroup + \dedicated@size #1\par + \egroup} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADDRESS +\def\address{\@ifnextchar[{\address@fmt}{\address@fmt[]}} + +\def\address@fmt[#1]#2{% + \smart@par% + \let\author@fmt@init\author@fmt@init@def + \vskip\address@skip% + {\address@style\address@size\leavevmode\ifx.#1.\else\usethankscounter{addressref}\thanksmark{#1}\restorethankscounter\fi#2\par}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AFFILIATION + +\def\affiliation{\@ifnextchar[{\affiliation@fmt}{\affiliation@fmt[]}} + +\def\affiliation@fmt[#1]#2{% + \smart@par% + \let\author@fmt@init\author@fmt@init@def% + \vskip\affiliation@skip% + \def\affiliation@skip{\z@}% + \bgroup + \affiliation@size% + \leavevmode% + \ifx.#1.\else\usethankscounter{addressref}\thanksmark{#1}\restorethankscounter\fi% + #2\par + \egroup +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CONTRIBUTOR +% For LNMS we must write as index entry: +% \contributor{Author, F.}{University} +% \indexentry{Author, F., \textit {Some University}}{} + +\let\contributor\@gobbletwo +\if@supertoc + \def\contributor#1#2{% + \addtocontents{idx}{\protect\indexentry{#1, \protect\textit{#2}}{}}% + } +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COPYRIGHTOWNER + +\def\copyright@fmt{% + \@ifundefined{\copyrightowner@text}{}{\safe@footnotetext{\copyright@owner}} + } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ABSTRACT + +\newbox\abstract@box + +\define@key{abstract}{language}{\set@loc@hyphenation{#1}\set@loc@abstractname{#1}} + +\gdef\abstract{\@ifnextchar[{\@abstract}{\@abstract[]}} + +\def\@abstract[#1]{% + \setkeys{abstract}{#1}% + \global\setbox\abstract@box=\vbox\bgroup% + \ifvoid\abstract@box\else% + \unvbox\abstract@box% + \vskip\abstract@skip% + \fi% + \@tempdima\textwidth% + \advance\@tempdima by-\abstract@width% + \divide\@tempdima by2% + \abstract@style% + \leftskip\@tempdima\rightskip\@tempdima% + \abstract@size% + \parindent\sv@parindent% + \noindent\hskip\abstract@indent{\abstractname@size\abstractname\abstractname@skip}\ignorespaces} + +\def\endabstract{\par\egroup} + +\def\abstract@fmt{% + \ifvoid\abstract@box\else + \vskip\abstract@skip% + \unvbox\abstract@box + \fi} + +\def\set@loc@hyphenation#1{% + \@ifundefined{l@#1}{}{\expandafter\language\csname l@#1\endcsname}} + +\def\set@loc@abstractname#1{% + \def\abstractname@english{Abstract} + \def\abstractname@german{Zusammenfassung} + \def\abstractname@french{R\'esum\'e} + \def\abstractname@spanish{Resumen.} + \@ifundefined{abstractname@#1}% + {\@latex@error{Nera kalbos '#1` palaikymo!}{}}% + {\edef\abstractname{\csname abstractname@#1\endcsname}}% +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HISTORY: received, revised, accepted + +\def\history@exist{0} + +\def\received#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@received{#1}\gdef\history@exist{1}\fi} + \def\@received{\@nil} +\def\revised#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@revised{#1}\gdef\history@exist{1}\fi} + \def\@revised{\@nil} +\def\accepted#1{\def\@tempa{#1}\ifx\@tempa\@empty\else\gdef\@accepted{#1}\gdef\history@exist{1}\fi} + \def\@accepted{\@nil} + +\def\empty@data{\@nil} + +\def\history@fmt{% + \ifcase\history@exist\else% + \bgroup + \nobreak% + \vskip\history@skip% + \nobreak% + \history@style% + \history@size% + \@tempdima\textwidth% + \advance\@tempdima by-\history@width% + \divide\@tempdima by2% + \leftskip\@tempdima + \rightskip\@tempdima + \leavevmode + \history@prefix + \ifx\@received\empty@data \else + \received@prefix\@received \received@postfix% + \fi + \ifx\@revised\empty@data \else + \revised@prefix\@revised \revised@postfix% + \fi + \ifx\@accepted\empty@data \else + \accepted@prefix\@accepted \accepted@postfix% + \fi + \history@postfix\par% + \egroup% + \gdef\history@exist{0} +\fi +} + +\def\sday#1{#1} +\def\smonth#1{\@ifundefined{month@item@#1}% + {\@latex@error{Nera tokio menesio, kurio numeris #1!}{??}}% + {\getitemvalue{month}{#1}}% + }% +\def\syear#1{#1} +\setvaluelist{month}{January,February,March,April,May,June,July,August,September,October,November,December} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% KEYWORDS + +\newbox\keyword@box +\newdimen\pre@kwd@depth + +\setattribute{keyword}{AMS}{AMS 2000 subject classifications:} +\setattribute{keyword}{MSC}{MSC 2010 subject classifications:} +\setattribute{keyword}{MSC2010}{MSC 2010 subject classifications:} + +\setattribute{keyword}{KWD}{Keywords and phrases:} +% raktas=class +\setattribute[default]{keyword}{class}{KWD} + +% \keyword@class-> KWD +% \keyword@KWD -> AMS 2000... + +\gdef\keyword{\@ifnextchar[{\@keyword}{\@keyword[class=KWD]}} + +\gdef\@keyword[#1]{% + \do@option@list{keyword}{#1}% + \def\keyword@name{\csname keyword@\keyword@class\endcsname}% + \let\kwd@sep\relax +% + \global\setbox\keyword@box=\vbox\bgroup% + \ifvoid\keyword@box\else% + \unvbox\keyword@box + \vskip-\pre@kwd@depth\vtop to\pre@kwd@depth{}% + \fi + \@tempdima\textwidth% + \advance\@tempdima by-\keyword@width% + \divide\@tempdima by2% + \keyword@style% + \leftskip\@tempdima\rightskip\@tempdima% + \keyword@size% + \parindent\sv@parindent% + \noindent\hskip\keyword@indent{\keywordname@size\keyword@name}\space\hskip.1pt} + +\def\endkeyword{\keyword@postfix\par\global\pre@kwd@depth\prevdepth\egroup} + +\def\keyword@fmt{% + \ifvoid\keyword@box\else + \vskip\keyword@skip% + \unvbox\keyword@box + \fi} + + +% \kwd[; ]{foo} + \def\sep{\unskip\string, }% + \newif\if@firstkeywordinlist \@firstkeywordinlisttrue + + \DeclareRobustCommand*\kwd{\@ifnextchar[\@kwd{\@kwd[\kwd@sep]}}% + \def\@kwd[#1]#2{\unskip#1{#2}\if@firstkeywordinlist\addto@keywords@list{#2}\@firstkeywordinlistfalse\else\addto@keywords@list{, #2}\fi\let\kwd@sep\sep}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \maketitle +% if \frontmatter is not used, we will redefine \maketitle + +\def\local@maketitle{% + \global\@topnum\z@ + \set@pagerange + \markboth{\@runauthor}{\@runtitle}% + \thispagestyle{copyright}% +% + \put@fmt@data% +% +% \print@titlepage +% + \write@pdfinfo{\hy@author}{\the\authors@list} + \write@pdfinfo{\hy@keywords}{\the\keywords@list} + \hy@endfrontmatter + \global\mathsurround\sv@mathsurround + \global\c@footnote\z@ + \global\let\@thanks\@empty + \let\title\relax + \let\author\relax + \let\address\relax + \let\frontmatter\relax \let\endfrontmatter\relax + \let\@maketitle\relax \let\@@maketitle\relax + \normalfont\normaltext + \parindent\sv@parindent + \frontmatter@cmd + } + +\AtBeginDocument{\let\maketitle\local@maketitle} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROCESS LAYOUT OPTIONS + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put keywords as footnote +\if@keywordsasfootnote + + \newtoks\keyword@toks + + \newpseudoenvironment{keyword}{\gdef\keyword@exist{1}\get@keyword@toks}{} + + \def\get@keyword@toks#1\end{\keyword@toks=\expandafter{\the\keyword@toks\keyword#1\endkeyword}\@gobble} + + \def\keyword@exist{0} + + \gdef\keyword#1{\@ifnextchar[{\@keyword}{\@keyword[class=KWD]}} + + \gdef\@keyword[#1]{% + \do@option@list{keyword}{#1}% + \def\keyword@name{\csname keyword@\keyword@class\endcsname}% + \let\kwd@sep\relax% + \keyword@style% + \keyword@size% + \parindent\sv@parindent% + \pre@kwd% + \hbox{\keywordname@size\keyword@name}\space\hskip.1pt}% + + \gdef\endkeyword{\gdef\pre@kwd{\par\leavevmode}} + + \let\pre@kwd\relax + + \def\keyword@fmt{\ifcase\keyword@exist\else\safe@footnotetext{\the\keyword@toks}\fi} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put history as footnote +\if@historyasfootnote + + \def\history@fmt{% + \ifcase\history@exist\else% + \safe@footnotetext{% + \nobreak% + \history@style% + \history@size% + \leavevmode + \history@prefix + \ifx\@received\empty@data \else + \received@prefix\@received \received@postfix% + \fi + \ifx\@revised\empty@data \else + \revised@prefix\@revised \revised@postfix% + \fi + \ifx\@accepted\empty@data \else + \accepted@prefix\@accepted \accepted@postfix% + \fi + \history@postfix}%\par}% + \fi} + + + + + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put address as footnote +\if@addressasfootnote + \def\address@fmt[#1]#2{% + \ifx.#1.% + \safe@footnotetext{#2} + \else% + \usethankscounter{addressref}% + \bgroup + \def\\{\hfill\break} + \thankstext{#1}{#2}% + \egroup + \restorethankscounter% + \fi% + } +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Put address at end +\if@addressatend +\def\address{\@ifnextchar[{\address@fmt}{\address@fmt[default]}} +% +% \def\address@ref@A=1 +% \newtoks\@address@1 +% \@address@1={#2} +% +\def\address@fmt[#1]#2{% + \stepcounter{address}% + \expandafter\protected@xdef\csname address@ref@#1\endcsname{\the\c@address}% + \expandafter\newtoks\csname @address@\the\c@address\endcsname + \expandafter\expandafter\expandafter\global\csname @address@\the\c@address\endcsname={#2}} + +\let\safe@phantomsection\@gobble + +% print address by number: \printaddressnum{1} +\def\printaddressnum#1{% +\xdef\@tmp{#1}% +\bgroup +\@ifundefined{@address@#1}{\@latex@error{Error: there are no address with number '#1'!}{??}}{ + \address@size + \ifnum#1=1% + \safe@phantomsection{\addcontentsline{toc}{section}{Author's addresses}}% + \fi% + \begin{tabular}[t]{@{}l@{}} + \expandafter\expandafter\expandafter\the\csname @address@\@tmp\endcsname + \end{tabular}} +\egroup +} + +% print all addresses: +\def\address@par{\par\vskip3pt} + +\def\printaddresses{% +\vskip\address@skip% +%\addcontentsline{toc}{section}{Author's addresses}% +\def\last@right@glue{\par}% +\ifodd\c@address \def\last@right@glue{\hfill\hbox{}\address@par} \fi% +\ifnum\c@address=1 \def\last@right@glue{\address@par}\fi% +\@tempcnta=0% +\bgroup\parindent\z@ +\@whilenum{\@tempcnta<\c@address}% + \do{% + \advance\@tempcnta\@ne + \ifodd\@tempcnta \def\left@glue{} \def\right@glue{} % nelyginis + \else \def\left@glue{\hfill} \def\right@glue{\address@par}\fi % lyginis + \ifnum\@tempcnta=\c@address \let\left@glue\hfill \let\right@glue\last@right@glue\fi %paskutinis narys + \left@glue\expandafter\printaddressnum{\the\@tempcnta}\right@glue% + } +\egroup +} + +% invoke \printaddresses at end of document: +\let\old@enddocument\enddocument +\def\enddocument{\printaddresses\old@enddocument} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the IMS journals (AOP, AAP, AOS) layout: +\if@imslayout + + \setattribute{title} {skip} {12\p@} + \setattribute{abstractname}{skip} {} + \setattribute{frontmatter} {cmd} {\vskip20\p@ plus 3\p@ minus 3\p@} + + \setattribute{abstract} {width} {23pc} + \setattribute{abstract} {indent} {16pt} %2em + + \setattribute{title} {size} {\normalsize\bfseries\mathversion{bold}\spaceskip.5em} + \setattribute{author} {size} {\normalsize\scshape} + \setattribute{affiliation}{size} {\normalsize\itshape} + \setattribute{address} {size} {\scriptsize\scshape} + \setattribute{ead} {size} {\upshape} + \setattribute{abstractname}{size}{\itshape} + \setattribute{keywordname}{size} {\itshape} + \setattribute{runninghead}{size} {\footnotesize} + \setattribute{pagenumber} {size} {\small} + \setattribute{copyright} {size} {\fontsize{6}{7}\selectfont\raggedright} + \setattribute{thebibliography}{size}{\footnotesize} + + \setattribute{dochead} {case} {\MakeUppercase} + \setattribute{title} {case} {\MakeUppercase} + \setattribute{runninghead}{case} {\MakeUppercase} + + \setattribute{author} {prefix} {By~} + + \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% + \@ifnonempty{\@copyrightyear\@volume\@issue\@pagerange\break}% + \doi@text} + + \setattribute{email} {text} {E-mail: } + \setattribute{url} {text} {URL: } + \setattribute{fullurl} {text} {URL: } + \def\volume#1{\gdef\@volume{Vol. #1, }} + \def\issue#1 {\gdef\@issue{No. #1, }} + \def\pubyear#1{\gdef\@pubyear{#1,}\gdef\@copyrightyear{#1 }} + + \def\abstractname{} + + \def\put@fmt@data{% + \copyright@fmt% + \history@fmt + \@thanks% + \keyword@fmt% + \abstract@fmt% + } + + \def\contentsname@cmd{\specialsection*{\contentsname}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the STS journal layout: + +\if@stslayout + + \setattribute{frontmatter} {style} {\raggedright} + \setattribute{title} {style} {\noindent\raggedright} + \setattribute{author} {style} {\noindent\raggedright} + \setattribute{address} {style} {\raggedright} + + \setattribute{title} {skip} {6\p@} + \setattribute{authors} {skip} {10pt} + \setattribute{address} {skip} {\z@} + \setattribute{abstract} {skip} {36\p@} + \setattribute{abstractname}{skip} {. } + \setattribute{keyword} {skip} {8\p@} + + \setattribute{abstract} {width} {28pc} + \setattribute{keyword} {width} {28pc} + + \setattribute{dochead} {size} {\sffamily\Large\fontseries{bx}\selectfont\spaceskip.5em} + \setattribute{title} {size} {\sffamily\fontseries{bx}\fontsize{24.88}{26}\selectfont\mathversion{bold}\spaceskip.5em} + \setattribute{author} {size} {\sffamily\large\fontseries{bx}\selectfont} + \setattribute{address} {size} {\normalfont\normalsize\itshape} + \setattribute{affiliation} {size} {\small\mdseries} + \setattribute{ead} {size} {} + \setattribute{abstract} {size} {\normalsize\mdseries\upshape} + \setattribute{abstractname} {size} {\itshape} + \setattribute{keyword} {size} {\normalsize\mdseries\upshape} + \setattribute{keywordname} {size} {\itshape} + \setattribute{thebibliography}{size} {\footnotesize} + \setattribute{copyright} {size} {\normalfont\mdseries\fontsize{6}{7}\selectfont\raggedright} + \setattribute{runninghead} {size} {\footnotesize} + \setattribute{runninghead} {case} {\MakeUppercase} + \setattribute{pagenumber} {size} {\small\bfseries} + + \setattribute{keyword} {KWD}{Key words and phrases:} + +% \printead: + \def\printead@fmt#1{(#1)} + +% all addresses are combined: + \newtoks\address@toks + + \def\address@exist{0} + + \def\address{\@ifnextchar[{\@address}{\@address[]}} + + \def\@address[#1]#2{ + \gdef\address@exist{1} + \begingroup% + \no@harm% + \xdef\@act{\global\noexpand\address@toks{\the\address@toks#2\ }}\@act + \endgroup} + + \def\address@fmt{\ifcase\address@exist\else\safe@footnotetext{\hskip-\parindent\address@style\address@size\the\address@toks}\fi} + + \def\put@fmt@data{% + \copyright@fmt% + \address@fmt% + \@thanks% + \abstract@fmt% + \keyword@fmt% + \if@twocolumn% + \frontmatter@cmd% + \fi} + + \def\firstpage@cmd{% + \if@twocolumn + \markboth{\@runauthor}{\@runtitle}% + \address@fmt% + \@thanks + \fi} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the BJ journal layout: + +\if@bjlayout + + \setattribute{frontmatter} {style} {\raggedright} + \setattribute{title} {style} {\noindent\raggedright} + \setattribute{author} {style} {\noindent\raggedright} + \setattribute{address} {style} {\raggedright} + + \setattribute{title} {skip} {10\p@} + \setattribute{abstract} {skip} {16\p@} + \setattribute{abstractname}{skip} {} + + \setattribute{abstract} {width} {\textwidth} + \setattribute{keyword} {width} {\textwidth} + \setattribute{history} {width} {\textwidth} + + \setattribute{dochead} {size} {\normalsize\MakeUppercase} + \setattribute{title} {size} {\fontsize{21}{26}\selectfont} + \setattribute{author} {size} {\normalsize} + \setattribute{fnms} {size} {\uppercase} + \setattribute{snm} {size} {\uppercase} + + \setattribute{address} {size} {\small\itshape} + \setattribute{abstract} {size} {\small\upshape} + \setattribute{keyword} {size} {\small\upshape} + \setattribute{keywordname}{size} {\itshape} + \setattribute{history} {size} {\raggedright\small\itshape} + + \setattribute{runninghead}{size} {\normalsize\itshape} + \setattribute{pagenumber} {size} {\normalsize\upshape} + \setattribute{copyright} {size} {\normalsize} + \setattribute{footline} {size} {\footnotesize} + + \setattribute{email} {text} {E-mail:~} + \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\ \textbf{\@volume}\@issue\@pubyear\ \@pagerange\\ + \doi@text} + \setattribute{history} {postfix} {} + \setattribute{revised} {prefix} { and revised~} + + \setattribute{keyword}{KWD}{Keywords:} + + \def\put@fmt@data{% + \copyright@fmt% + \@thanks% + \abstract@fmt% + \keyword@fmt% + \tableofcontents@fmt} + + % invoke \printhistory at end of document: + \let\old@enddocument\enddocument + \def\enddocument{\history@fmt\old@enddocument} + + \def\volume#1{\gdef\@volume{#1}} + \def\issue#1{\gdef\@issue{(#1)}} + \def\pubyear#1{\gdef\@pubyear{, #1, }\gdef\@copyrightyear{, #1, }} + + \def\abstractname{} + + \def\evenhead@fmt#1{\hfill#1} + \def\oddhead@fmt#1{#1\hfill} + + \def\fnum@table{\tablename~\thetable.} + + \long\def\@maketablecaption#1#2{% + \centering\footnotesize + \textbf{#1}\enskip #2\par + \vskip\belowcaptionskip} + + \renewcommand\figurename{Figure} + + \long\def\@makecaption#1#2{% + \vskip\abovecaptionskip + \footnotesize + \textbf{#1}. #2\par + \vskip\belowcaptionskip} + + +\fi + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the AIHP journal layout: + +\if@aihplayout + + % FRONT MATTER SKIPS + \setattribute{title} {skip} {64\p@} + \setattribute{authors} {skip} {14\p@} + \setattribute{address} {skip} {12\p@} + \setattribute{abstractname}{skip} {.\enskip} + \setattribute{history} {skip} {4\p@} + \setattribute{abstract} {skip} {16\p@} + + \setattribute{fline} {cmd} {\vskip22\p@ + \hrule} + \setattribute{lline} {cmd} {\vskip10\p@ + \hrule} + + % FRONT MATTER DIMENSIONS + \setattribute{abstract} {width} {\textwidth} + \setattribute{abstract} {indent} {\z@} + \setattribute{keyword} {width} {\textwidth} + \setattribute{keyword} {indent} {\z@} % + + % FRONT MATTER FONTS + \setattribute{title} {size} {\huge} + \setattribute{author} {size} {\Large} + \setattribute{abstract} {size} {\small\upshape} + \setattribute{keywordname}{size} {\itshape} + \setattribute{thebibliography}{size}{\footnotesize} + + \def\put@fmt@data{% + \copyright@fmt% + \@thanks% + \history@fmt + \fline@cmd% + \abstract@fmt% + \keyword@fmt% + \lline@cmd% + \tableofcontents@fmt} + + \setattribute{keyword}{KWD}{Keywords:} + \setattribute{email}{text}{E-mail: } + + \def\theaddressref{\alph{addressref}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Set up parameters for the BJPS journal layout: + +\if@bjpslayout + + \setattribute{keyword}{AMS}{AMS 2000 subject classifications.} + \setattribute{keyword}{KWD}{Keywords and phrases.} + + \setattribute{abstractname}{skip} {.\enskip} + + \setattribute{title} {size} {\Large\bfseries\mathversion{bold}} + \setattribute{address} {size} {\scriptsize} + \setattribute{keywordname}{size} {\itshape} + \setattribute{runninghead}{size} {\footnotesize} + \setattribute{pagenumber} {size} {\small} + \setattribute{thebibliography}{size}{\footnotesize} + + \setattribute{copyright} {text} {\url@fmt{}{\itshape}{\journal@name}{\journal@url}\break% + \@ifnonempty{\@volume\@pubyear\@pagerange\break}% + \@ifnonempty{\journal@issn\break}% + \doi@text}% + + \setattribute{email} {text}{E-mail: } + \setattribute{url} {text}{URL: } + \setattribute{fullurl}{text}{URL: } + + \def\thethanks{\@arabic\c@thanks} + \def\theaddressref{\alph{addressref}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% smart \MR +%% code suggested by Vilmos Prokaj +%% solves the problem when MR is in a format +%% \MR{MR1037262 (91i:60148)} + +% without MR this macro removes the MR prefix if it +% is present unchange the argument otherwise +\def\woMR#1{\w@MR#1MR#1MR\relax}% +\def\w@MR#1MR#2MR#3\relax{#2} + +% this splits MR... (...) +\def\@MR#1 #2\relax#3{% + \href{http://www.ams.org/mathscinet-getitem?mr=#1}% + {\MRfixed{#3}}}% + +\def\MRfixed{MR\woMR}% + +\let\MR\MRfixed + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% interaction with hyperref + +\def\test@hyperref{\@ifundefined{Hy@SetCatcodes}{}{\imsart@hyperref@settings}} + +\AtBeginDocument{\test@hyperref} + +\def\imsart@hyperref@settings{% +% +% hooks for the \thanksref, \thankstext: + \def\thankref@hyperlink##1{% + \edef\@tempx{##1thanks}% + \hbox{\hyperlink{##1}{\saferef{\@tempx}}}} + \def\thanks@hypertarget##1{\smash{\raise\baselineskip\hbox{\protect\hypertarget{##1}{}}}} +% redefine pagenumbering + \let\pagenumbering\ims@pagenumbering +% activate href + \let\ims@href\href% + \let\safe@phantomsection\phantomsection +% put document info + \def\write@pdfinfo##1##2{\protected@write\@auxout{\no@harm}{\string\gdef\string##1{##2}}} + \@ifundefined{hy@title}{}{\pdfstringdef\@pdftitle{\hy@title}} + \@ifundefined{hy@author}{}{\pdfstringdef\@pdfauthor{\hy@author}} + \@ifundefined{hy@subject}{}{\pdfstringdef\@pdfsubject{\hy@subject}} + \@ifundefined{hy@keywords}{}{\pdfstringdef\@pdfkeywords{\hy@keywords}} +% + \@ifundefined{user@hy@title}{}{\global\let\@pdftitle\user@hy@title} + \@ifundefined{user@hy@author}{}{\global\let\@pdfauthor\user@hy@author} + \@ifundefined{user@hy@subject}{}{\global\let\@pdfsubject\user@hy@subject} + \@ifundefined{user@hy@keywords}{}{\global\let\@pdfkeywords\user@hy@keywords} +% +% MathSciNet: +% \def\MR##1{\href{http://www.ams.org/mathscinet-getitem?mr=##1}{MR##1}} + + %% MR with hyperef + \def\MR##1{\@MR##1 \relax{##1}}% + + +% \@ifundefined{Hy@SetCatcodes}{\let\MR\MRfixed}{\relax}% + +} + +\def\write@pdfinfo#1#2{} + +\newtoks\authors@list +\def\addto@authors@list#1{% + \begingroup% + \no@harm% + \xdef\@act{\global\noexpand\authors@list{\the\authors@list#1}}\@act% + \endgroup} + +\newtoks\keywords@list +\def\addto@keywords@list#1{% + \begingroup% + \no@harm% + \xdef\@act{\global\noexpand\keywords@list{\the\keywords@list#1}}\@act% + \endgroup} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION, SUBSECTION ETC. +% we do not like article appearance: + +\renewcommand\section{\@startsection {section}{1}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\raggedright\bfseries\mathversion{bold}}} + +\renewcommand\subsection{\@startsection {subsection}{2}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\raggedright\bfseries\itshape\mathversion{bold}}} + +\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\raggedright\itshape}} + +\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {\medskipamount}% + {-1em}% + {\bfseries}} + +\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% + {\medskipamount}% + {-1em}% + {\itshape}} + + +% Format for the counter: +\def\section@numbersep{.} +\def\subsection@numbersep{.} +\def\subsubsection@numbersep{.} +\def\paragraph@numbersep{.} +\def\subparagraph@numbersep{.} + +\def\@seccntformat#1{{\csname #1@prefix\endcsname\csname the#1\endcsname\csname#1@numbersep\endcsname\enspace}} + + +\let\specialsection\section + +\@namedef{specialsection*}{\section*} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: bjpslayout + +\if@bjpslayout + + \renewcommand\section{\@startsection {section}{1}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\large\bfseries\mathversion{bold}\raggedright}} + + \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% + {-\medskipamount}% + {\smallskipamount}% + {\bfseries\mathversion{bold}\raggedright}} + + \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {\medskipamount}% + {-10pt}% + {\normalsize\itshape}} + + \def\subsubsection@prefix{\upshape} + + \def\section@numbersep{} + \def\subsection@numbersep{} + \def\subsubsection@numbersep{} + \def\paragraph@numbersep{} + \def\subparagraph@numbersep{} +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: IMS layout + +\if@imslayout + \renewcommand\section{\@startsection {section}{1}{\parindent}% + {\medskipamount}% + {-10pt}% + {\normalsize\upshape\bfseries\mathversion{bold}}} + + \renewcommand\subsection{\@startsection {subsection}{2}{\parindent}% + {\medskipamount}% + {-10pt}% + {\subsection@shape}} + \def\subsection@shape{\normalsize\itshape} + \def\subsection@prefix{\upshape} + + \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\parindent}% + {\medskipamount}% + {-10pt}% + {\normalsize\itshape}} + \def\subsubsection@prefix{\upshape} + + \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {\smallskipamount}% + {-1em}% + {\normalsize\itshape}} + \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% + {0.1pt}% + {-1em}% + {\normalsize\itshape}} + +% must be used for the appendix \section and \thebibliography + \renewcommand\specialsection{\@startsection {section}{1}{\z@}% + {\medskipamount}% + {\smallskipamount}% + {\normalsize\centering\MakeUppercase}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: STS layout + +\if@stslayout + + \def\sec@raggedright{% + \def\\{\hfill\break}\@rightskip\@flushglue \rightskip\@rightskip + \leftskip\z@skip + \parindent\z@} + +% last line will centered to page width + + \def\fl@hangfrom#1{\noindent {#1}} + \def\TO@fl{\let\@hangfrom\fl@hangfrom} + + + \renewcommand\section{\@startsection {section}{1}{\z@}% + {\medskipamount}% + {\smallskipamount}% + {\centering\TO@fl\normalsize\sffamily\fontseries{bx}\selectfont\mathversion{bold}\MakeUppercase}} + + \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% + {\smallskipamount}% + {\smallskipamount}% + {\normalsize\sffamily\fontseries{bx}\selectfont\mathversion{bold}\sec@raggedright}} + + \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\parindent}% + {\smallskipamount}% + {-.5em}% + {\normalsize\itshape}} + + \renewcommand\paragraph{\@startsection{paragraph}{4}{\parindent}% + {\z@}% + {-4pt}% + {\normalsize\itshape}} + + \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\z@}% + {0.1pt}% + {-1em}% + {\normalsize\itshape}} + +% must be used for the \thebibliography + \renewcommand\specialsection{\@startsection {section}{1}{\z@}% + {\bigskipamount}% + {\smallskipamount}% + {\normalsize\centering\MakeUppercase}} + +% Format for the counter: + \def\section@numbersep{.} + \def\subsection@numbersep{} + \def\subsubsection@numbersep{} + \def\paragraph@numbersep{} + \def\subparagraph@numbersep{} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: BJ layout + +\if@bjlayout + + \renewcommand\section{\@startsection {section}{1}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\Large\bfseries\mathversion{bold}\raggedright}} + + \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% + {-\bigskipamount}% + {\medskipamount}% + {\large\bfseries\mathversion{bold}\raggedright}} + + \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-\medskipamount}% + {\smallskipamount}% + {\itshape\raggedright}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sections: AIHP layout + +\if@aihplayout + + \renewcommand\subsection{\@startsection {subsection}{2}{\z@}% + {-\medskipamount}% + {\medskipamount}% + {\itshape\raggedright}} + + \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-\medskipamount}% + {.01\p@}% + {\itshape\raggedright}} + + \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {\medskipamount}% + {-10pt}% + {\itshape}} + + \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% + {0.1pt}% + {-1em}% + {\itshape}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \thanksref will not print "??" if label is undefined + +\if@noundefthanksref + + \AtBeginDocument{\let\sv@thankref@hyperlink\thankref@hyperlink}% + + \def\thanksref@hook{% + \@ifundefined{r@\@tempb thanks}{% + \let\thankref@hyperlink\@gobble% + \let\@tempa\@empty}% + {\let\thankref@hyperlink\sv@thankref@hyperlink}% + } + +\fi +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% loading of amsmath + +\def\set@amsthm{ + \def\ims@thmshape{0} + \if@imslayout \def\ims@thmshape{1}\fi + \if@stslayout \def\ims@thmshape{1}\fi + \if@bjlayout \def\ims@thmshape{2}\fi + \if@aihplayout \def\ims@thmshape{3}\fi + \if@bjpslayout \def\ims@thmshape{3}\fi + + \ifcase\ims@thmshape + \or %1 + \thm@notefont{\upshape} + \newtheoremstyle{plain} {\medskipamount}{\medskipamount}{\itshape}{\parindent}{\scshape}{.}{1em}{} + \newtheoremstyle{definition}{\medskipamount}{\medskipamount}{\normalfont}{\parindent}{\scshape}{.}{1em}{} + \newtheoremstyle{remark} {\medskipamount}{\medskipamount}{\normalfont}{\parindent}{\scshape}{.}{1em}{} + + \renewenvironment{proof}[1][\proofname]{\par + \pushQED{\qed}% + \normalfont \topsep\medskipamount% + \trivlist + \labelsep.5em% + \item[\hskip\labelsep\hskip\parindent + \scshape ##1\@addpunct{.}]\ignorespaces + }{% + \popQED\endtrivlist\@endpefalse + } + \or %2 + + \newtheoremstyle{plain} {\medskipamount}{\medskipamount}{\itshape}{\z@}{\bfseries}{.}{1em}{} + \newtheoremstyle{definition}{\medskipamount}{\medskipamount}{\itshape}{\z@}{\bfseries\itshape}{.}{1em}{} + \newtheoremstyle{remark} {\medskipamount}{\medskipamount}{\normalfont}{\z@}{\bfseries\itshape}{.}{1em}{} + + \renewenvironment{proof}[1][\proofname]{\par + \pushQED{\qed}% + \normalfont \topsep\medskipamount\relax + \trivlist + \item[\hskip\labelsep + \itshape\bfseries + ##1\@addpunct{.}]\ignorespaces + }{% + \popQED\endtrivlist\@endpefalse + } + + + \or %3 + + \renewenvironment{proof}[1][\proofname]{\par + \pushQED{\qed}% + \normalfont \topsep\medskipamount\relax + \trivlist + \item[\hskip\labelsep + \bfseries + ##1\@addpunct{.}]\ignorespaces + }{% + \popQED\endtrivlist\@endpefalse + } + + \else + \fi} + + +\if@load@amsmath + \if@amsmath@leqno + \PassOptionsToPackage{leqno}{amsmath} + \fi + \RequirePackage[cmex10]{amsmath} +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% loading of amsthm + +\if@load@amsthm + \RequirePackage{amsthm} + \set@amsthm +\else + \AtBeginDocument{\@ifpackageloaded{amsthm}{\set@amsthm}{}} +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thebibliography, loading natbib + +%%% \citefix -- fixes \NAT@citex (to make a hyperlink from year component in cite command). +\def\citefix{% + \def\NAT@citex% + [##1][##2]##3{% + \NAT@sort@cites{##3}% + \let\@citea\@empty + \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty + \@for\@citeb:=\NAT@cite@list\do + {\edef\@citeb{\expandafter\@firstofone\@citeb}% + \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi + \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea% + {\reset@font\bfseries ?}\NAT@citeundefined + \PackageWarning{natbib}% + {Citation `\@citeb' on page \thepage \space undefined}\def\NAT@date{}}% + {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year + \NAT@parse{\@citeb}% + \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{% + \let\NAT@name=\NAT@all@names + \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}% + \fi + \ifNAT@full\let\NAT@nm\NAT@all@names\else + \let\NAT@nm\NAT@name\fi + \ifNAT@swa\ifcase\NAT@ctype + \if\relax\NAT@date\relax + \@citea\NAT@nmfmt{\NAT@nm}% + \hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@date\hyper@natlinkend + \else + \ifx\NAT@last@nm\NAT@nm\NAT@yrsep + \ifx\NAT@last@yr\NAT@year + \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab + \hyper@natlinkend + \else\unskip\ + \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date + \hyper@natlinkend + \fi + \else + \@citea\NAT@nmfmt{\NAT@nm}% + \NAT@aysep\ + \hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@date\hyper@natlinkend + \fi + \fi + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@nmfmt{\NAT@nm}\hyper@natlinkend + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@date\hyper@natlinkend + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@alias\hyper@natlinkend + \fi \def\@citea{\NAT@sep\ }% + \else\ifcase\NAT@ctype + \if\relax\NAT@date\relax + \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@nmfmt{\NAT@nm}\hyper@natlinkend + \else + \ifx\NAT@last@nm\NAT@nm\NAT@yrsep + \ifx\NAT@last@yr\NAT@year + \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab + \hyper@natlinkend + \else\unskip\ + \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date + \hyper@natlinkend + \fi + \else + \@citea\NAT@nmfmt{\NAT@nm}% + \ \NAT@@open\if*##1*\else##1\ \fi + \hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@date\hyper@natlinkend\fi + \fi + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@nmfmt{\NAT@nm}\hyper@natlinkend + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@date\hyper@natlinkend + \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + \NAT@alias\hyper@natlinkend + \fi \if\relax\NAT@date\relax\def\@citea{\NAT@sep\ }% + \else\def\@citea{\NAT@@close\NAT@sep\ }\fi + \fi + }}\ifNAT@swa\else\if*##2*\else\NAT@cmt##2\fi + \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{##1}{##2}}% + \let\@citex\NAT@citex +} + + +\def\set@natbib{% + \if@linksfromyear \citefix \fi + \let\bibfont\thebibliography@size + \setlength\bibsep{0pt}} + +\if@load@natbib + \RequirePackage{natbib} + \set@natbib +\else + \let\xxx@thebibliography\thebibliography + \def\thebibliography{\thebibliography@size\xxx@thebibliography} + \g@addto@macro\@openbib@code{\itemsep\z@} + \AtBeginDocument{\@ifpackageloaded{natbib}{\set@natbib}{}} +\fi + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% thebibliography - structured + +%%%%%%%%% Common macros: + +% Setting a "style" for a command: +% \set@bibl@cmd{bvolume} == \def\bvolume#1{{\bvolume@style #1}} + +\def\set@bibl@cmd#1{\expandafter\def\csname #1\endcsname##1{{\csname #1@style\endcsname##1}}} + +\let\endbibitem\relax + +%%%%%%%%% bauthor, beditor + +\def\bbl@bauthor#1{% + \csname bauthor@hook\endcsname% +{% + \let\binits\@firstofone% + \let\bsnm\@firstofone% + \let\bfnm\@gobble% + \let\bparticle\@firstofone% + \let\bsuffix\@firstofone% + \bauthor@style% +#1}} + +\def\bbl@beditor#1{{% + \let\binits\@firstofone% + \let\bsnm\@firstofone% + \let\bfnm\@gobble% + \let\bparticle\@firstofone% + \let\bsuffix\@firstofone% + \beditor@style% +#1}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bid +% \bid{MR={},doi={},...} + +\define@key{bid}{mr}{\MR{#1}} +\define@key{bid}{doi}{} +\define@key{bid}{pubmed}{} +\define@key{bid}{pii}{} +\define@key{bid}{issn}{} + +\def\bbl@bid#1{% + \setkeys{bid}{#1}% +} + +% for compatibility with old bibtex style +\def\bdoi#1{\ignorespaces} + +%%%%%%%%% common@pub@types + +\def\common@pub@types{% + \def\AND{and }% + \let\betal\@firstofone% + \set@bibl@cmd{btitle}% + \let\byear\@firstofone% + \let\bpages\@firstofone% + \let\bmisc\@firstofone% + \let\bnote\@firstofone% + \let\banumber\@firstofone% + \let\bmrnumber\MR% + \let\bid\bbl@bid% + \set@bibl@cmd{bvolume}% + \csname common@pub@types@hook\endcsname% +} + + +%%%%%%%%% default stiliai + + \setattribute{bauthor}{style}{\scshape} + \setattribute{beditor}{style}{\scshape} + + \setattribute{bjournal} {style}{\itshape} + \setattribute{bbooktitle}{style}{\itshape} + \setattribute{bseries} {style}{\itshape} + + \setattribute{bvolume} {style}{\bfseries} + +%%%%%%%%% barticle + +\def\barticle{\@ifnextchar[{\@barticle}{\@barticle[]}} + +\def\@barticle[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \set@bibl@cmd{bjournal}% +} + +%%%%%%%%% bbook + +\def\bbook{\@ifnextchar[{\@bbook}{\@bbook[]}} + +\def\@bbook[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\beditor\bbl@beditor% + \let\bedition\@firstofone% + \set@bibl@cmd{bseries}% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% +% + \let\btitle@style\itshape% +} + + +%%%%%%%%% bincollection + +\def\bincollection{\@ifnextchar[{\@bincollection}{\@bincollection[]}} + +\def\@bincollection[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\beditor\bbl@beditor% + \set@bibl@cmd{bbooktitle}% + \let\bchapter\@firstofone% + \let\bedition\@firstofone% + \set@bibl@cmd{bseries}% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% + \def\bauthor@hook{\let\beditor@style\relax} +} + +%%%%%%%%% binproceedings + +\def\binproceedings{\@ifnextchar[{\@binproceedings}{\@binproceedings[]}} + +\def\@binproceedings[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\beditor\bbl@beditor% + \set@bibl@cmd{bbooktitle}% + \set@bibl@cmd{bseries}% + \let\borganization\@firstofone% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% +} + +%%%%%%%%% binbook + +\def\binbook{\@ifnextchar[{\@binbook}{\@binbook[]}} + +\def\@binbook[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\beditor\bbl@beditor% + \set@bibl@cmd{bbooktitle}% + \let\bchapter\@firstofone% + \let\bedition\@firstofone% + \set@bibl@cmd{bseries}% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% +% + \let\btitle@style\itshape +} + + +%%%%%%%%% bproceedings + +\def\bproceedings{\@ifnextchar[{\@bproceedings}{\@bproceedings[]}} + +\def\@bproceedings[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\beditor\bbl@beditor% + \let\bedition\@firstofone% + \set@bibl@cmd{bseries}% + \let\bpublisher\@firstofone% + \let\borganization\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% +% + \let\btitle@style\itshape +} + + +%%%%%%%%% btechreport + +\def\btechreport{\@ifnextchar[{\@btechreport}{\@btechreport[]}} + +\def\@btechreport[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\btype\@firstofone% + \let\bnumber\@firstofone% + \let\binstitution\@firstofone% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% +} + +%%%%%%%%% bmanual + +\def\bmanual{\@ifnextchar[{\@bmanual}{\@bmanual[]}} + +\def\@bmanual[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\bedition\@firstofone% + \let\borganization\@firstofone% + \let\bpublisher\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% + \let\bisbn\@gobble% +} + +%%%%%%%%% mastersthesis + +\def\bmastersthesis{\@ifnextchar[{\@bmastersthesis}{\@bmastersthesis[]}} + +\def\@bmastersthesis[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\bschool\@firstofone% + \let\bpublisher\@firstofone% + \let\btype\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% +} + +%%%%%%%%% phdthesis + +\def\bphdthesis{\@ifnextchar[{\@bphdthesis}{\@bphdthesis[]}} + +\def\@bphdthesis[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\bpublisher\@firstofone% + \let\bschool\@firstofone% + \let\btype\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% +} + +%%%%%%%%% bbooklet + +\def\bbooklet{\@ifnextchar[{\@bbooklet}{\@bbooklet[]}} + +\def\@bbooklet[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\bhowpublished\@firstofone% + \let\baddress\@firstofone% + \let\blocation\@firstofone% +} + +%%%%%%%%% bunpublished + +\def\bunpublished{\@ifnextchar[{\@bunpublished}{\@bunpublished[]}} + +\def\@bunpublished[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% +} + +%%%%%%%%% bmisc + +\def\bmisc{\@ifnextchar[{\@bmisc}{\@bmisc[]}} + +\def\@bmisc[#1]{% + \common@pub@types% + \let\bauthor\bbl@bauthor% + \let\bhowpublished\@firstofone% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bptok + +\def\bptok#1{\ignorespaces} + +\ifx\OrigBibText\undefined \long\def\OrigBibText#1\endOrigBibText{}\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% appendix + +\if@imslayout + +% appendix mess up everything in this layout: + + \renewcommand\appendix{\par + \def\subsection@shape{\normalsize\upshape\bfseries\mathversion{bold}} + \let\section\specialsection + \def\section{\@ifnextchar*{\@appsectionstar}{\@appsectionnostar}}% + \def\section@prefix{\appendixname\ }% + \def\section@numbersep{:}% + \setcounter{section}{0}% + \setcounter{subsection}{0}% + \gdef\thesection{\@Alph\c@section}} + +% \section*{Appendix} -> APPENDIX + \def\@appsectionstar*#1{% + \specialsection*{#1}% + \setcounter{section}{1}% +% \addcontentsline{toc}{section}{#1} +} + +% \section{} -> APPENDIX A +% \section{proof} -> APPENDIX A: PROOF + \def\@appsectionnostar#1{% + \ifx.#1.% + \def\section@numbersep{}\specialsection[\appendixname\ \thesection]{}% + \else% + \def\section@numbersep{:}\specialsection{#1}% + \fi} + +% dirty trick with \thebibliography + \let\old@thebibliography\thebibliography + \def\thebibliography{\let\section\specialsection\old@thebibliography} + +\else + + \renewcommand\appendix{\par + \let\old@section\section% + \def\section{\@ifnextchar*{\@appsectionstar}{\@appsectionnostar}}% + \def\section@prefix{\appendixname\ }% + \def\section@numbersep{:}% + \setcounter{section}{0}% + \setcounter{subsection}{0}% + \gdef\thesection{\@Alph\c@section}} + + \def\@appsectionstar*#1{% + \old@section*{#1}% + \setcounter{section}{1}% +% \addcontentsline{toc}{section}{#1} +} + + \def\@appsectionnostar#1{% + \ifx.#1.% + \def\section@numbersep{}\old@section[\appendixname\ \thesection]{}% + \else% + \def\section@numbersep{:}\old@section{#1}% + \fi} + + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% supplement +% +%\begin{supplement}[id=suppA] +% \sname{Supplement A} +% \stitle{} +% \slink[doi]{} +% \slink[url]{http://lib.stat.cmu.edu/aoas/???/???} +% \sdatatype{.zip} +% \sfilename{foo.zip} +% \sdescription{} +%\end{supplement} +% \thesuppdoi{suppA} +% \ref{suppA} +% \hyperlink{suppA}{text} + +\def\supplement@name{Supplementary Material} + +\def\sname#1{\def\@sname{#1}\def\@currentlabel{#1}} +\def\stitle#1{\def\@stitle{#1}} +\def\sdatatype#1{\def\@sdatatype{#1}} +\def\sfilename#1{} +\def\slink[#1]#2{\expandafter\def\csname slink@#1\endcsname{#2}} +\def\sdescription#1{\def\@sdescription{#1}} + +\def\suppsection@fmt{\specialsection*{\supplement@name}} + +\def\slink@doi@fmt{% + \url@fmt{doi: }{}{\slink@doi}{\doi@base\slink@doi}% + \@ifundefined{supp@label}{}{% + \expandafter\xdef\csname\supp@label @doi\endcsname{\slink@doi}% + \expandafter\xdef\csname\supp@label @url\endcsname{\doi@base\slink@doi}}% +} + +\def\slink@url@fmt{% + \url@fmt{}{}{\slink@url}{\slink@url}% + \@ifundefined{supp@label}{}{% + \expandafter\xdef\csname\supp@label @url\endcsname{\slink@url}}% +} + +\def\thesuppdoi#1{\@ifundefined{#1@doi}% + {\@latex@error{Undefined supplement id=#1}{??}}% + {\def\@tempx{\csname #1@doi\endcsname}% + \@ifundefined{#1@url}{\def\@tempy{\doi@base\csname #1@url\endcsname}}{\def\@tempy{\csname #1@url\endcsname}}% + \url@fmt{DOI: }{}{\@tempx}{\@tempy}}% +} + +\define@key{supplement}{id}{\def\supp@label{#1}} + +\long\def\supplement{\@ifnextchar[{\@supplement}{\@supplement[]}} + +\long\def\@supplement[#1]{% + \suppsection@fmt% + \global\let\suppsection@fmt\smallskip% + \setkeys{supplement}{#1}% +} + +\def\endsupplement{% + \@ifundefined{@sname}{}{\@ifundefined{supp@label}{}{\hypertarget{\supp@label}{}\label{\supp@label}}\textbf{\@sname: }}% + \@ifundefined{@stitle}{}{\textbf{\@stitle\ }}% +% + \\ + (% + \@ifundefined{slink@doi}{}{\slink@doi@fmt}% + \@ifundefined{slink@url}{}{\slink@url@fmt}% + \@ifundefined{@sdatatype}{}{; \@sdatatype}% + ). + \@ifundefined{@sdescription}{}{\@sdescription}% + \par} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOC in "article" class is a mess: + + +% for hyperref +\def\toclevel@title{0} + +\newcommand*\l@title[2]{} +\newcommand*\l@author[2]{} +\newcommand*\l@doi[2]{} +\newcommand*\l@arxiv[2]{} +\newcommand*\l@jobname[2]{} +\newcommand*\l@begintocitem[2]{} +\newcommand*\l@endtocitem[2]{} + +\newif\if@changetoc \@changetocfalse +\@ifclassloaded{article}{\@changetoctrue}{} + +\if@changetoc + + \@ifundefined{contentsname@cmd}{\def\contentsname@cmd{\section*{\contentsname}}}{} + + \renewcommand\tableofcontents{% + \nocontentsline + \contentsname@cmd% + \@starttoc{toc}% + } + + \renewcommand*\l@section{\@dottedtocline{1}{\z@}{1.5em}} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% number lines + +\ifnumberlines@ + + \long\def\l@addto@macro#1#2{% + \toks@\expandafter{#1#2}% + \edef#1{\the\toks@}} + + \setattribute{numberlines}{size}{\scriptsize\ttfamily} + \setattribute{numberlines}{skip}{24\p@} + + \def\numberlines@hook{% + \l@addto@macro\@evenhead\put@numberlines@box% + \l@addto@macro\@oddhead\put@numberlines@box} + + \g@addto@macro\ps@imsheadings\numberlines@hook + \g@addto@macro\ps@copyright\numberlines@hook + + \newbox\numberlines@box + \newskip\numberlines@box@skip + + \def\set@numberlines@box{% + \setlength\numberlines@box@skip\headsep + \addtolength\numberlines@box@skip{5\p@} + % + \setbox\numberlines@box\vtop to\textheight{% + \parindent\z@ + \vskip\z@ + \@tempcnta=0 + \@tempdima=\z@ + \loop + \advance\@tempcnta by1 + \advance\@tempdima by\baselineskip + \hbox to\textwidth{% + \llap{\numberlines@size\the\@tempcnta\kern\numberlines@skip} + \hfill + \rlap{\numberlines@size\kern\numberlines@skip\the\@tempcnta}} + \ifdim\@tempdima<\textheight\repeat + \vss + }% + % + \ht\numberlines@box\z@ + \dp\numberlines@box\z@ + } + + \def\put@numberlines@box{\lower\numberlines@box@skip\hbox to\z@{\hss\copy\numberlines@box}} + + \AtBeginDocument{\set@numberlines@box} + +\fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INICIALIZATION + +% Read local configuration file (if exist): +% imsart.cnf imsart-ps.cnf imsart-lnms.cnf + +\@input{\imsfmt@name\journal@id.cnf} + + +\@twosidetrue +\pagenumbering{arabic} +\frenchspacing +\init@settings +\pagestyle{imsheadings} + +\endinput +%% +%% History: +2014.10.16 - added \qq{} +2014.10.13 - added \OrigBibText and \endOrigBibText +2014.07.30 - removed \raggedright from \relateddois +2014.07.23 - added \relateddoi and \relateddois +2014.02.20 - "Submitted to the Bernoulli" changed to "Submitted to Bernoulli"; +2014.01.08 - "Submitted to the Statistical Science" changed to "Submitted to Statistical Science"; +2013.05.28 - keyword key MSC added (MSC 2010 subject classifications:); +2013.03.06 - added \bpublisher for the \bmanual entry; +2012.08.31 - bug fix in stslayout; +2012.08.16 - added new bibliography commands; +2012.04.10 - bug fix in stslayout; +2010.03.13 - new option linksfromyear (makes a hyperlink only from year component of the cite command); +2012.02.28 - SSY - references layout changed; +2012.02.07 - new option noundefthanksref (SSY journal); +2011.12.06 - empty command \sfilename added; +2011.12.01 - when \title is centered, \\ is defined as \break; +2011.11.28 - bugfix in \title command; + - \thanksref made robust; +2011.11.15 - small fixes related to the webbib tagging; +2011.11.15 - minor change: bug fix when contructing keywords list for pdf's metadata; +2011.05.20 - SS journal url changed; +2011.03.02 - SSY copyright fixed; +2011.01.24 - \bdoi added; +2010.09.07 - journal url changed for EJS journal; +2010.08.03 - \tableofcontents fixed for the imslayout journals; +2010.04.27 - support for the "Stochastic Systems" (ssy) added; +2009.12.16 - \betal added +2009.08.13 - support for the structured bibliography added (imsart-number.bst,imsart-nameyear.bst) + options [numbers,sort&compress] from natbib package removed +2009.05.21 - added new option "bjps" +2009.02.27 - all hyperref links are set to "blue" + - smart \MR command (code suggested by Vilmos Prokaj +2008.08.29 - supplement environment added +2008.01.24 - for "coll" changed journal url +2008.01.09 - added new option "coll" +2007.12.10 - added new option "aihp" + - abstract have an attribute language= + - multiple abstracts + - \atltitle{} - title in another language +2007.09.18 - fixed small error in SS (affiliation) +2007.04.13 - fixed small error in EJS +2007.04.02 - ISSN numbers of EJS and SS included +2007.02.20 - support for the "Electronic Journal of Statistics" (ejs) added; +2007.01.24 - support for the "The Annals of Applied Statistics" (aoas) and Bernoulli (bj) added; +2006.10.13 - small bug with "lnms, ps, ss" options fixed; +2006.09.07 - if no options specified, imsart.sty is loaded with "generic" option; + - new options: imslayout, stslayout +2006.08.23 -"author's addresses" secion added to bookmarks (aap,aop,aos); + -completely new STS layout; + -\tableofcontents adjusted, could be used in frontmatter part; + -support for LNMS Table of Contents; + -support for LNMS "List of Contributors" (\contributor{Author, F.}{University}); + -command \arxiv{math.PR/0000000} introduced to provide link to article location in arXiv + -\@journal{} changed to \journal@name + -\ead{} correctly sets the pdf link when "http://" prefix is used; + -\ead[...,nopdflink]{} supresses pdf link; + -a lot of internal changes; + - fix of a bug with newer hyperref versions (\orig@footnotetext) + -equation numbers are at left for LNMS layout; + +2006.03.07 -command \volumename{} introduced + small changes for LNMS option + (addresses will be positioned on title page) + -pdf document properties could be changed with commands + \pdftitle{}, \pdfsubject{}, \pdfauthor{} + +2006.01.04 support for the "Statistics Surveys" (ss) added; + +2005.10.19 fix of a bug with bibliography and ims layout + \@footnotetext is changed due to the arXiv hyperref setup + +2005.05.19 New options singlespacing, doublespacing, linenumbers, nolinenumbers introduced; + Table and figure captions changed + +%% End of file `imsart.sty'. diff --git a/manuscript/aoas/musicManuscript.pdf b/manuscript/tempopaper/aoas/musicManuscript.pdf similarity index 100% rename from manuscript/aoas/musicManuscript.pdf rename to manuscript/tempopaper/aoas/musicManuscript.pdf diff --git a/manuscript/aoas/musicManuscript.tex b/manuscript/tempopaper/aoas/musicManuscript.tex similarity index 100% rename from manuscript/aoas/musicManuscript.tex rename to manuscript/tempopaper/aoas/musicManuscript.tex diff --git a/manuscript/arxiv/Archive.zip b/manuscript/tempopaper/arxiv/Archive.zip similarity index 100% rename from manuscript/arxiv/Archive.zip rename to manuscript/tempopaper/arxiv/Archive.zip diff --git a/manuscript/arxiv/music-arxiv.pdf b/manuscript/tempopaper/arxiv/music-arxiv.pdf similarity index 100% rename from manuscript/arxiv/music-arxiv.pdf rename to manuscript/tempopaper/arxiv/music-arxiv.pdf diff --git a/manuscript/arxiv/music-arxiv.tex b/manuscript/tempopaper/arxiv/music-arxiv.tex similarity index 100% rename from manuscript/arxiv/music-arxiv.tex rename to manuscript/tempopaper/arxiv/music-arxiv.tex diff --git a/manuscript/chopinrefs.bib b/manuscript/tempopaper/chopinrefs.bib similarity index 100% rename from manuscript/chopinrefs.bib rename to manuscript/tempopaper/chopinrefs.bib diff --git a/manuscript/dirichlet_precision.R b/manuscript/tempopaper/dirichlet_precision.R similarity index 100% rename from manuscript/dirichlet_precision.R rename to manuscript/tempopaper/dirichlet_precision.R diff --git a/manuscript/gfx/alternative-smoothers-1.pdf b/manuscript/tempopaper/gfx/alternative-smoothers-1.pdf similarity index 100% rename from manuscript/gfx/alternative-smoothers-1.pdf rename to manuscript/tempopaper/gfx/alternative-smoothers-1.pdf diff --git a/manuscript/gfx/bad-model-1.pdf b/manuscript/tempopaper/gfx/bad-model-1.pdf similarity index 100% rename from manuscript/gfx/bad-model-1.pdf rename to manuscript/tempopaper/gfx/bad-model-1.pdf diff --git a/manuscript/gfx/ballade-top.pdf b/manuscript/tempopaper/gfx/ballade-top.pdf similarity index 100% rename from manuscript/gfx/ballade-top.pdf rename to manuscript/tempopaper/gfx/ballade-top.pdf diff --git a/manuscript/gfx/clust-1-1.pdf b/manuscript/tempopaper/gfx/clust-1-1.pdf similarity index 100% rename from manuscript/gfx/clust-1-1.pdf rename to manuscript/tempopaper/gfx/clust-1-1.pdf diff --git a/manuscript/gfx/clust-2-1.pdf b/manuscript/tempopaper/gfx/clust-2-1.pdf similarity index 100% rename from manuscript/gfx/clust-2-1.pdf rename to manuscript/tempopaper/gfx/clust-2-1.pdf diff --git a/manuscript/gfx/clust-3-1.pdf b/manuscript/tempopaper/gfx/clust-3-1.pdf similarity index 100% rename from manuscript/gfx/clust-3-1.pdf rename to manuscript/tempopaper/gfx/clust-3-1.pdf diff --git a/manuscript/gfx/clust-4-1.pdf b/manuscript/tempopaper/gfx/clust-4-1.pdf similarity index 100% rename from manuscript/gfx/clust-4-1.pdf rename to manuscript/tempopaper/gfx/clust-4-1.pdf diff --git a/manuscript/gfx/clust-densities-1.pdf b/manuscript/tempopaper/gfx/clust-densities-1.pdf similarity index 100% rename from manuscript/gfx/clust-densities-1.pdf rename to manuscript/tempopaper/gfx/clust-densities-1.pdf diff --git a/manuscript/gfx/clust-densities-sub1-1.pdf b/manuscript/tempopaper/gfx/clust-densities-sub1-1.pdf similarity index 100% rename from manuscript/gfx/clust-densities-sub1-1.pdf rename to manuscript/tempopaper/gfx/clust-densities-sub1-1.pdf diff --git a/manuscript/gfx/clust-densities-sub2-1.pdf b/manuscript/tempopaper/gfx/clust-densities-sub2-1.pdf similarity index 100% rename from manuscript/gfx/clust-densities-sub2-1.pdf rename to manuscript/tempopaper/gfx/clust-densities-sub2-1.pdf diff --git a/manuscript/gfx/clust-other-1.pdf b/manuscript/tempopaper/gfx/clust-other-1.pdf similarity index 100% rename from manuscript/gfx/clust-other-1.pdf rename to manuscript/tempopaper/gfx/clust-other-1.pdf diff --git a/manuscript/gfx/cortot-performance-1.pdf b/manuscript/tempopaper/gfx/cortot-performance-1.pdf similarity index 100% rename from manuscript/gfx/cortot-performance-1.pdf rename to manuscript/tempopaper/gfx/cortot-performance-1.pdf diff --git a/manuscript/gfx/hatto-1.pdf b/manuscript/tempopaper/gfx/hatto-1.pdf similarity index 100% rename from manuscript/gfx/hatto-1.pdf rename to manuscript/tempopaper/gfx/hatto-1.pdf diff --git a/manuscript/gfx/mazurka-first-10.pdf b/manuscript/tempopaper/gfx/mazurka-first-10.pdf similarity index 100% rename from manuscript/gfx/mazurka-first-10.pdf rename to manuscript/tempopaper/gfx/mazurka-first-10.pdf diff --git a/manuscript/gfx/mazurka-top.pdf b/manuscript/tempopaper/gfx/mazurka-top.pdf similarity index 100% rename from manuscript/gfx/mazurka-top.pdf rename to manuscript/tempopaper/gfx/mazurka-top.pdf diff --git a/manuscript/gfx/parametric-clusters-1.pdf b/manuscript/tempopaper/gfx/parametric-clusters-1.pdf similarity index 100% rename from manuscript/gfx/parametric-clusters-1.pdf rename to manuscript/tempopaper/gfx/parametric-clusters-1.pdf diff --git a/manuscript/gfx/parametric-clusters-2.pdf b/manuscript/tempopaper/gfx/parametric-clusters-2.pdf similarity index 100% rename from manuscript/gfx/parametric-clusters-2.pdf rename to manuscript/tempopaper/gfx/parametric-clusters-2.pdf diff --git a/manuscript/gfx/raw-data-clusters-1.pdf b/manuscript/tempopaper/gfx/raw-data-clusters-1.pdf similarity index 100% rename from manuscript/gfx/raw-data-clusters-1.pdf rename to manuscript/tempopaper/gfx/raw-data-clusters-1.pdf diff --git a/manuscript/gfx/richter-1.pdf b/manuscript/tempopaper/gfx/richter-1.pdf similarity index 100% rename from manuscript/gfx/richter-1.pdf rename to manuscript/tempopaper/gfx/richter-1.pdf diff --git a/manuscript/gfx/rubinstein-perfs-1.pdf b/manuscript/tempopaper/gfx/rubinstein-perfs-1.pdf similarity index 100% rename from manuscript/gfx/rubinstein-perfs-1.pdf rename to manuscript/tempopaper/gfx/rubinstein-perfs-1.pdf diff --git a/manuscript/gfx/similar-perfs-1.pdf b/manuscript/tempopaper/gfx/similar-perfs-1.pdf similarity index 100% rename from manuscript/gfx/similar-perfs-1.pdf rename to manuscript/tempopaper/gfx/similar-perfs-1.pdf diff --git a/manuscript/gfx/small-rubinstein-1961-1.pdf b/manuscript/tempopaper/gfx/small-rubinstein-1961-1.pdf similarity index 100% rename from manuscript/gfx/small-rubinstein-1961-1.pdf rename to manuscript/tempopaper/gfx/small-rubinstein-1961-1.pdf diff --git a/manuscript/gfx/two-performances-1.pdf b/manuscript/tempopaper/gfx/two-performances-1.pdf similarity index 100% rename from manuscript/gfx/two-performances-1.pdf rename to manuscript/tempopaper/gfx/two-performances-1.pdf diff --git a/manuscript/tempopaper/jasa-reject/JASA_ACS_author_form.docx b/manuscript/tempopaper/jasa-reject/JASA_ACS_author_form.docx new file mode 100644 index 0000000..0a3cd9c Binary files /dev/null and b/manuscript/tempopaper/jasa-reject/JASA_ACS_author_form.docx differ diff --git a/manuscript/jasa-reject/musicManuscript.pdf b/manuscript/tempopaper/jasa-reject/musicManuscript.pdf similarity index 100% rename from manuscript/jasa-reject/musicManuscript.pdf rename to manuscript/tempopaper/jasa-reject/musicManuscript.pdf diff --git a/manuscript/jasa-reject/musicManuscript.tex b/manuscript/tempopaper/jasa-reject/musicManuscript.tex similarity index 100% rename from manuscript/jasa-reject/musicManuscript.tex rename to manuscript/tempopaper/jasa-reject/musicManuscript.tex diff --git a/manuscript/jasa-reject/reviews.md b/manuscript/tempopaper/jasa-reject/reviews.md similarity index 100% rename from manuscript/jasa-reject/reviews.md rename to manuscript/tempopaper/jasa-reject/reviews.md diff --git a/manuscript/music-supplement.Rmd b/manuscript/tempopaper/music-supplement.Rmd similarity index 100% rename from manuscript/music-supplement.Rmd rename to manuscript/tempopaper/music-supplement.Rmd diff --git a/manuscript/music-supplement.pdf b/manuscript/tempopaper/music-supplement.pdf similarity index 100% rename from manuscript/music-supplement.pdf rename to manuscript/tempopaper/music-supplement.pdf diff --git a/manuscript/music-supplement.tex b/manuscript/tempopaper/music-supplement.tex similarity index 100% rename from manuscript/music-supplement.tex rename to manuscript/tempopaper/music-supplement.tex diff --git a/manuscript/tempopaper/musicManuscript-blinded.pdf b/manuscript/tempopaper/musicManuscript-blinded.pdf new file mode 100644 index 0000000..c45dc28 Binary files /dev/null and b/manuscript/tempopaper/musicManuscript-blinded.pdf differ diff --git a/manuscript/tempopaper/musicManuscript.pdf b/manuscript/tempopaper/musicManuscript.pdf new file mode 100644 index 0000000..7050242 Binary files /dev/null and b/manuscript/tempopaper/musicManuscript.pdf differ diff --git a/manuscript/tempopaper/musicManuscript.tex b/manuscript/tempopaper/musicManuscript.tex new file mode 100644 index 0000000..78fd868 --- /dev/null +++ b/manuscript/tempopaper/musicManuscript.tex @@ -0,0 +1,1611 @@ +\documentclass[12pt]{article} + +% JASA necessities -------- +% NOTE: To produce blinded version, replace "1" with "0" below. +\newcommand{\blind}{1} +\pdfminorversion=4 +% DON'T change margins - should be 1 inch all around. +% Daniel: This stuff seems not to have that effect despite the JASA +% template's claim (the bottom margin is huge) +% \addtolength{\oddsidemargin}{-.5in}% +% \addtolength{\evensidemargin}{-.5in}% +% \addtolength{\textwidth}{1in}% +% \addtolength{\textheight}{-.3in}% +% \addtolength{\topmargin}{-.8in}% +\usepackage[margin=1in]{geometry} % use this instead + +\def\spacingset#1{\renewcommand{\baselinestretch}% +{#1}\small\normalsize} \spacingset{1} +% End JASA stuff -------------- + +\usepackage{setspace} + +\usepackage[letterpaper=true,colorlinks=true,pdfpagemode=none,urlcolor=blue,linkcolor=blue,citecolor=blue,pdfstartview=FitH]{hyperref} +\usepackage{amsmath,amsfonts,amssymb} +\usepackage{graphicx} +\usepackage{color} +\usepackage[round,sort&compress]{natbib} +\usepackage{algorithm,algorithmic} +\def\algorithmautorefname{Algorithm} +\renewcommand{\algorithmiccomment}[1]{\hfill $\rhd$ #1} +\renewcommand*{\figureautorefname}{Figure}% +\renewcommand*{\tableautorefname}{Table}% +\renewcommand*{\partautorefname}{Part}% +\renewcommand*{\chapterautorefname}{Chapter}% +\renewcommand*{\sectionautorefname}{Section}% +\renewcommand*{\subsectionautorefname}{Section}% +\renewcommand*{\subsubsectionautorefname}{Section}% + + +\usepackage{pgf} +\usepackage{tikz} +\usetikzlibrary{fit,arrows,automata} % fitting shapes to coordinates +\usetikzlibrary{backgrounds} +\tikzstyle{state}=[circle,thick,minimum size=1.2cm, draw=black] +% The (continuous) measurement vector is represented by an orange circle. +\tikzstyle{measurement}=[circle,thick,minimum size=1.2cm,draw=black, +fill=gray!25] +\tikzstyle{switch}=[rectangle,thick, minimum size=1cm, draw=black] + +\usepackage{wasysym} + + +\usepackage{booktabs} +\renewcommand{\arraystretch}{1.2} + + +% \usepackage{xr} +% \externaldocument{music-supplement} + + + +% Bibliography + + +\graphicspath{{gfx/},{figs-for-paper_files/figure-latex/}} +%\renewcommand{\includegraphics}[2][]{} + +% Number only ref'ed equations +\usepackage{mathtools} +\mathtoolsset{showonlyrefs,showmanualtags} + +\newcommand{\attn}[1]{\textcolor{red}{Note: #1}} +\newcommand{\norm}[1]{\left\lVert #1 \right\rVert} +\renewcommand{\hat}{\widehat} +% next three lines to give Kalman filter sample \varx_t=E[x_t|y_1,...,y_t] +\usepackage{upgreek} +\DeclareRobustCommand{\varx}{{\mathpalette\irchi\relax}} +\newcommand{\irchi}[2]{\protect\raisebox{\depth}{$#1\upchi$}} +\newcommand{\given}{\ \vert\ } +\newcommand{\E}{\mathbb{E}} +\newcommand{\Expect}[1]{\E\left[#1\right]} +\newcommand{\Var}[1]{\mathbb{V}\left[#1\right]} +\newcommand{\indicator}[1]{\boldsymbol{1}\left(#1\right)} +\newcommand{\email}[1]{\href{mailto:#1}{#1}} + + +\begin{document} + +\if1\blind +{ +\title{Markov-switching State Space Models for Uncovering Musical Interpretation} +\author{Daniel J. McDonald\thanks{Daniel J.\ McDonald is Associate + Professor, Department of Statistics, Indiana University, + Bloomington, IN 47405 (e-mail: \email{dajmcdon@indiana.edu}); + Michael McBride is Undergraduate, Department of Statistics, Indiana University, + Bloomington, IN 47405 (e-mail: \email{michmcbr@iu.edu}); + Yupeng Gu is Postdoctoral Researcher, Department of Informatics, Indiana University, + Bloomington, IN 47405 (e-mail: \email{yupeng.gu@gmail.com}); + and Christopher Raphael is Professor, School of Informatics, + Computing, and Engineering, Indiana University, + Bloomington, IN 47405 (e-mail: \email{craphael@indiana.edu}); + This work was partially supported by + the National Science Foundation Grants DMS-1407439 + and DMS-1753171 (to DJM) and Grant IIS-1526473 (to CR).} + \and + Michael McBride + \and + Yupeng Gu + \and + Christopher Raphael + } +\maketitle +} \fi + +% For JASA blinding------------ +\if0\blind +{ + \bigskip + \bigskip + \bigskip + \begin{center} + {\LARGE\bf Markov-switching State Space Models for Uncovering Musical Interpretation} +\end{center} + \medskip +} \fi +% end blinding --------------- + +\bigskip +\begin{abstract} +For concertgoers, musical interpretation is the most important factor +in determining whether or not we enjoy a classical performance. Every +performance includes mistakes---intonation issues, a lost note, an +unpleasant sound---but these are all easily forgotten (or unnoticed) when a performer +engages her audience, imbuing a piece with novel emotional content +beyond the vague instructions inscribed on the printed page. While music teachers use +imagery or heuristic guidelines to motivate interpretive decisions, combining these +vague instructions to create a convincing performance remains the domain +of the performer, subject to the whims of the moment, technical +fluency, and taste. In this +research, we use data from the CHARM Mazurka Project---forty-six professional +recordings of Chopin's Mazurka Op.\ 63 No.\ 3 by consumate artists---with the goal of +elucidating musically interpretable performance decisions. Using information on the +inter-onset intervals of the note attacks in the recordings, we apply functional data +analysis techniques enriched with prior information gained from music +theory to discover relevant features and perform hierarchical +clustering. The resulting clusters suggest methods for informing music +instruction, discovering listening preferences, and analyzing performances. + +%The text of your abstract. 200 or fewer words. At 172 currently +\end{abstract} + +\noindent% +{\it Keywords:} classification and clustering; Kalman filter; hidden Markov model; +\vfill + +\newpage + +\spacingset{1.45} % DON'T change the spacing! + +%\tableofcontents + + + + + + + + + + +\section{Introduction} +\label{sec:introduction} + +% \attn{See \href {http://amstat.tfjournals.com/asa-style-guide/}{here} +% for the style guide (detailed) and +% \href{https://www.tandfonline.com/action/authorSubmission?journalCode=uasa20&page=instructions}{here} +% for the author instructions.} + +Statistical analysis of the musical content of recordings has +become more and more important to academics and industry. Online +music services like Pandora, Last.fm, Spotify, and others rely on +recommendation systems to suggest potentially interesting or related +songs to listeners. In 2011, the KDD Cup challenged academic computer +scientists and statisticians to identify user tastes in music with the +\href{http://labrosa.ee.columbia.edu/millionsong/}{Yahoo! Million + Song Dataset} (see \citet{DrorKoenigstein2012} for details of the +competition). Pandora, through its proprietary +\href{https://www.pandora.com/about/mgp}{Music Genome Project}, uses +trained musicologists to assign new songs a vector of trait +expressions (consisting of up to 500 ``genes'' depending on the genre) +which can then be used to measure similarity with other +songs. However, most of this work has focused on the analysis of more popular +and more profitable genres of music---pop, rock, country---as opposed +to classical music. + +Western classical music is a subcategory +whose boundaries are occasionally difficult to define. But +the distinction is of great importance when it comes to the analysis +which we undertake here. Leonard Bernstein, the great composer, +conductor, and pianist, gave the following characterization in one of his famous +``Young People's Concerts'' +broadcast by the Columbia Broadcasting Corporation in the 1950s and +1960s \citep{Bernstein2005}. +\begin{quote} + You see, everybody thinks he knows what classical music is: just any music that isn't jazz, + like a Stan Kenton arrangement or a popular song, like ``I Can't Give + You Anything but Love Baby,'' or folk music, like an African war + dance, or ``Twinkle, Twinkle Little Star.'' But that isn't what + classical music means at all. +\end{quote} +Bernstein goes on to discuss an important distinction between what +we often call ``classical music'' and other types of music which is +highly relevant to the current study. +\begin{quote} + The real difference is that when a composer + writes a piece of what's usually called classical music, he puts down + the exact notes that he wants, the exact instruments or voices that he + wants to play or sing those notes---even the exact number of + instruments or voices; and he also writes down as many directions as + he can think of. [...] Of course, no performance can be perfectly exact, because there + aren't enough words in the world to tell the performers everything + they have to know about what the composer wanted. But that's just what + makes the performer's job so exciting---to try and find out from what + the composer did write down as exactly as possible what he meant. Now + of course, performers are all only human, and so they always figure it + out a little differently from one another. +\end{quote} +What separates classical music from other types of music is that the +music itself is written down but performed millions of times in a +variety of interpretations. There is no ``gold standard'' recording to +which everyone can refer but rather a document created for +reference. Therefore, the musical genome technique mentioned above +will only relate ``pieces'' but not ``performances''. We need +new methods to decide whether we prefer Leonard Bernstein's +recording of Beethoven's Fifth Symphony or Herbert von Karajan's and +to articulate why. + + +In this paper, we develop a statistical model for some of the +decisions that a musician must make for classical music +interpretations. We focus on how the musician modulates +{\it tempo}, or speed, over the course of a recording. +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{richter-1} + \caption{Note-by-note tempos for a recording of Chopin's Mazurka + Op.\ 68 No.\ 3 by Sviatislav Richter. The solid line are the + observed tempos, while the dots represent inferred tempo states + from our model. } + \label{fig:richter} +\end{figure} +\autoref{fig:richter} shows the tempo\footnote{Technically, by + ``tempo'', we mean the ratio of musical time to clock time as $0.25$ + beats $/$ $0.1$ seconds $=$ 150 beats per minute. A musician would + likely think of ``tempo'' more broadly as something like a ``typical + speed regime'' akin to the ``constant tempo'' state we use in our + decision model below. We will not generally distinguish between + these two interpretations and use the more succinct ``tempo''.} + in beats-per-minute (b.p.m.) of +a recording made by Sviatislav Richter of Chopin's Mazurka Op.\ 68 +No.\ 3. The solid line shows the actual tempo at which he plays each +note, while the colored points correspond to our model's inferences +for his actual intentions. Some of this intent is prescribed by +Chopin in his music, but the extent to which Richter observes Chopin's +indications makes his recording different from those of other +pianists. It is these differences that we hope to capture and understand. + +\subsection{Related work} +\label{sec:related-work} + + + +The vast majority of work at the intersection of statistics or machine +learning and classical music analysis has focused on a handful of tasks, +most notably structure analysis, music generation, and score +alignment. + +Analysis of musical structure and its relationships with interpretation +forms the basis of music theory, and hence constitutes the core of standard +conservatory curricula, along with history and performance. Automatically learning musical structures +from performances without expert input has become more relevant +recently. \citet{RenDunson2010} use Dirichlet process models to identify +similar sections of individual classical music +performances. \citet{RobertsEngel2018} use variational autoencoders to +learn long-term structure with an explicit goal toward improved +automatic music composition. + +Computer music generation and composition has a long +history~\citep{SturmBen-Tal2019,Boulanger-LewandowskiBengio2012,Collins2016,Ariza2005,FlossmannGrachten2013}. +It is actively investigated, especially using deep +learning~\citep{HadjeresPachet2017}, and has become commercially +relevant for advertising and video games through companies like +Aiva (\url{aiva.ai}), and Melodrive (\url{melodrive.com}). Google has +developed the Magenta project to enable open-source music +composition~\citep{RobertsHawthorne2018}. + +The score alignment +problem matches live or recorded performances to the musical score, a necessary +processing step for any type of automated analysis. On-line alignment processes +audio waveforms in real-time +and is sometimes called score +following~\citep{DannenbergRaphael2006,Cont2010,ContSchwarz2007,ArztWidmer2015}. Audio +matched to the score can then be used as an input for automated +musical accompaniment~\citep{Raphael2010,Vercoe1985,Dannenberg1985}. +Given recorded accompaniment, these systems seek to +modulate playback in response to a live soloist who both makes +interpretive timing decisions and mistakes. Off-line alignment~\citep{Earis2007} can be +used for simply analyzing the recordings, as we do here, or for +generating features that describe the +performance~\citep{ThickstunHarchaoui2017}, possibly for later analysis +in recommender +systems~\citep{McFeeLanckriet2011,OordDieleman2013}. For an overview +of these and related goals in music information retrieval, see~\citet{schedl2014music}. + +\subsection{Our contributions} +\label{sec:our-contributions} + +In this paper, we develop a switching Kalman filter model for the +tempo decisions a performer makes in recorded classical music. We +present an algorithm for performing likelihood inference, estimate our +model using a large collection of recordings of the same composition, +and demonstrate how the model is able to recover performer intentions, +and how they relate to standard musical analysis. We use the learned +low-dimensional representations to compare and contrast the recordings +of different recordings through hierarchical clustering, and +discuss how this analysis facilitates more informed musical +comparisons of the recordings. + +In \autoref{sec:materials-methods} we discuss our dataset, a +collection of professional recordings of Chopin's Mazurka Op.\ 68 No.\ +3. We also present our model for tempo decisions, discuss it's +statistical estimation, and detail its utility for understanding +interpretations as a musician would. \autoref{sec:analys-chop-mazurka} +presents a music theory interpretation of the Mazurka. We discuss how +different performers approach this piece through the lens of our model. +We also examine a clustering based on our model and interpret the musical +meaning of these clusters. Finally, we contrast our approach with +some alternative non-parametric +smoothers, discusses their deficiencies relative our switching model, +and examine some issues with our proposal. + + + + +\section{Materials and methods} +\label{sec:materials-methods} + + + + +%\subsection{Data and preprocessing} + +In this paper, we examine note-by-note tempos for 46 recordings of +Chopin's Mazurka Op.\ 68, No.3. The data are part of a large +collection of the complete Chopin Mazurkas and other recordings +collected and analyzed by the Center for the History and Analysis of +Recorded Music (CHARM) in the United Kingdom~\citep{CHARM-site}. The +recordings were processed using the note-onset detection algorithm +developed in~\citep{Earis2007} and are available for +download~\citep{Earis2009}. We use the data for ``all rhythmic +events'', which includes the time of each note attack as well as it's +relative loudness. +%For the sake of reproducibility, we have included this data in our R package. + +\subsection{Switching state-space models} + +State-space models define the probability distribution of a continuous +time series $Y$ by reference to some imagined, continuous hidden state, $X$. In +particular, the observation at time $i$ is assumed to be +independent of past and future observations conditional on the state +at time $i$. Coupling with temporal dependence for $X$---most +frequently obeying the Markov property---induces a temporal model for +the observations. The most general form of a state-space model is +then characterized by the +measurement equation (the conditional probability of observations +given the states), +the transition equation (specifying the nature of Markovian +dynamics), and an initial distribution for the state: +\begin{equation} +\begin{aligned} + y_i &= f_\theta(x_i,\epsilon_i), & + x_{i+1} &= g_\theta(x_i,\eta_i), & + x_1 &\sim F, +\end{aligned} +\label{eq:ssmod} +\end{equation} +where $\epsilon_i$ are $\eta_i$ are marginally independent and +identically distributed as well as mutually independent. Both +$y_i$ and $x_i$ can be vector-valued, though in our +application, $y_i$ will be univariate. The +vector $\{y_i\}_{i=1}^n$ is observed, and the goal is to make +inferences for the unobserved states $\{x_i\}_{i=1}^n$ as well as any +unknown parameters $\theta$ characterizing $f_\theta$, $g_\theta$, and +the distributions of $\epsilon_i$ and $\eta_i$. +% \autoref{fig:ssmod} +% shows a directed acyclic graph for the dependence structure in the +% typical state-space model. + +% \begin{figure} +% \centering +% % The continuous state vector is represented by a circle. +% % "minimum size" makes sure all circles have the same size +% % independently of their contents. +% \begin{tikzpicture}[>=latex,text height=1.5ex,text +% depth=0.25ex,ampersand replacement=\&] +% \matrix[row sep=1cm,column sep=1cm] { +% % first line: hidden continuous state +% \node (x_k-2) {$\cdots$}; \& +% \node (x_k-1) [state] {$\mathbf{x}_{i-1}$}; \& +% \node (x_k) [state] {$\mathbf{x}_i$}; \& +% \node (x_k+1) [state] {$\mathbf{x}_{i+1}$}; \& +% \node (x_k+2) {$\cdots$}; +% \\ +% % Second line: Measurement +% \node (y_k-2) {$\cdots$}; \& +% \node (y_k-1) [measurement] {$\mathbf{y}_{i-1}$}; \& +% \node (y_k) [measurement] {$\mathbf{y}_i$}; \& +% \node (y_k+1) [measurement] {$\mathbf{y}_{i+1}$}; \& +% \node (y_k+2) {$\cdots$}; +% \\ +% }; +% % The diagram elements are now connected through arrows: +% \path[->] +% (x_k-2) edge (x_k-1) +% (x_k-1) edge (x_k) +% (x_k) edge (x_k+1) +% (x_k+1) edge (x_k+2) +% (x_k-1) edge (y_k-1) +% (x_k) edge (y_k) +% (x_k+1) edge (y_k+1); +% \end{tikzpicture} +% \caption{State-space model. Filled objects are observed, circles +% indicate that both hidden and observed states are +% continuous.\label{fig:ssmod}} +% \end{figure} + +If $f_\theta$ and $g_\theta$ are linear with $\epsilon_i$ and +$\eta_i$ normally distributed, Equation \eqref{eq:ssmod} becomes +\begin{equation} + \begin{aligned} + x_{i+1}&= d+T x_i + \eta_{i}, + & \eta_i &\sim N(0,\ Q), + &x_1 &\sim N(x_0,\ P_0),\\ + y_i&= c + Z x_i + \epsilon_i, + & \epsilon_i &\sim N(0,\ G), \\ + \end{aligned} + \label{eq:lgmod} +\end{equation} +where the matrices $d,\ T,\ c,\ Z,\ Q,$ and $G$ are allowed to depend +on $\theta$ and can potentially vary (deterministically) with $i$. In this case, +the Kalman filter, %\autoref{alg:kalman} +\citep[see e.g.,][]{Kalman1960,Harvey1990}, +provides closed form +solutions for the conditional +distributions of the states and gives the likelihood of $\theta$ +given data. For completeness, we have included the Kalman filter in +the Supplementary Material.% as \autoref{alg:kalman}. +% \begin{algorithm}[t!] +% \begin{singlespace} +% \caption{Kalman filter: estimate $x_i$ conditional on +% $\{y_j\}_{j=1}^i$, for all $i=1,\ldots,n$ and calculate the log likelihood +% for $\theta$\label{alg:kalman}} +% \begin{algorithmic} +% \STATE {\bf Input:} $Y$, $x_0$, $P_0$, $d,\ T,\ c,\ Z,$ and $G$ +% \STATE $\ell(\theta) \leftarrow 0$ \COMMENT{Initialize the log-likelihood} +% \FOR{$i=1$ to $n$} +% \STATE $\begin{aligned}\varx_{i} +% &\leftarrow d + T x_{i-1|i-1}, & P_i &\leftarrow Q + T P_{i-1|i-1} +% T^\top\end{aligned}$ \COMMENT{Predict current state} +% \STATE $\begin{aligned}\widetilde{y}_i +% &\leftarrow c + Z \varx_i, & F_i &\leftarrow G + Z P_i +% Z^\top\end{aligned}$ \COMMENT{Predict current observation} +% \STATE $\begin{aligned}v_i&\leftarrow y_i-\widetilde{y}_i& K_i& +% \leftarrow P_i Z^\top F^{-1}\end{aligned}$ \COMMENT{Forecast error and +% Kalman gain} +% \STATE $\begin{aligned} x_{i|i} +% &\leftarrow \varx_i + K_i v_i, & P_{i|i} &\leftarrow P_i - P_iZ^\top +% K_i\end{aligned}$ \COMMENT{Update} +% \STATE $\ell(\theta) = \ell(\theta) -v_i^\top F^{-1}v_i - \log(|F_i|)$ +% \ENDFOR +% \RETURN $\widetilde{Y}=\{\widetilde{y}_i\}_{i=1}^n,\ \varx=\{\varx_i\}_{i=1}^n,\ +% \widetilde{X}=\{x_{i|i}\}_{i=1}^n,\ P=\{P_i\}_{i=1}^n,\ +% \widetilde{P}=\{P_{i|i}\}_{i=1}^n,\ \ell(\theta)$ +% \end{algorithmic} +% \end{singlespace} +% \end{algorithm} + +% However, in many applications, researchers are not so +% lucky. For nonlinear or non-Gaussian models, approximate solutions +% exist using the particle filter and its derivatives (see for +% example~\citet{Kitagawa1987,Kitagawa1996} +% and~\citet{DoucetDe-Freitas2001} for an exposition of the particle +% filter and~\citet{KoyamaPerez-Bolde2010} +% and~\citet{DejongDharmarajan2009a} for improvements). + +While the Kalman filter %\autoref{alg:kalman} +returns the likelihood for $\theta$, +inference for the the mean and variance +of $X$ is conditional only on the preceding observations +$\{y_j\}_{j=1}^i$: $\varx_i=\Expect{x_i\given y_1\ldots,y_i}$ and +$P_i=\Var{x_i\given y_1,\ldots,y_i}$. To +incorporate all future observations into these estimates, the Kalman +smoother is required. +% \begin{algorithm}[t!] +% \begin{singlespace} +% \caption{Kalman smoother (Rauch-Tung-Striebel): estimate $\hat{X}$ conditional on +% $Y$\label{alg:kalman-smoother}} +% \begin{algorithmic} +% \STATE {\bf Input:} $\varx$, $\widetilde{X}$, $P$, $\widetilde{P}$, +% $T,$ $c$, $Z$. +% \STATE $t=n$, +% \STATE $\hat{x}_{n}\leftarrow \widetilde{x}_n$, +% \WHILE{$t>1$} +% \STATE $\hat{y}_i \leftarrow c + Z\hat{x}_i,$ +% \COMMENT{Predict observation vector} +% \STATE $\begin{aligned} e &\leftarrow \hat{x}_i - +% \varx_i, & V &\leftarrow P_i^{-1}\end{aligned}$, +% \STATE $t\leftarrow i-1$, \COMMENT{Increment} +% \STATE $\hat{x}_i = \widetilde{x}_i + \widetilde{P}_i T Ve $ +% \ENDWHILE +% \RETURN $\widehat{Y}=\{\hat{y}_i\}_{i=1}^n, \hat{X}=\{\hat{x}_i\}_{i=1}^n$ +% \end{algorithmic} +% \end{singlespace} +% \end{algorithm} +There are many different smoother algorithms tailored for different +applications. %\autoref{alg:kalman-smoother} (Supplementary Material), +The smoother we use, due +to~\citet{RauchStriebel1965}, is often referred to as the classical +fixed-interval smoother~\citep{AndersonMoore1979}. It produces only +the unconditional expectations of the hidden state +$\hat{x}_i=\Expect{x_i\given y_1,\ldots,y_n}$ for the sake of +computational speed. This version is more appropriate for inference in +the type of switching models we discuss below. We again provide this +algorithm in the Supplementary Material. + + +Linear Gaussian state-space models can be made quite flexible +by expanding the state vector or allowing the parameter matrices to +vary with time. Furthermore, this general form encompasses many +standard time series models: ARIMA models, ARCH and GARCH models, +stochastic volatility models, exponential smoothers, and +more~\citep[see][for many other +examples]{DurbinKoopman2001}. Nonlinear, non-Gaussian versions have +been extensively +studied~\citep{DurbinKoopman1997,Fuh2006,Kitagawa1987,Kitagawa1996} +and algorithms for filtering, smoothing, and parameter estimation have +been derived~\citep[e.g.,][]{KoyamaPerez-Bolde2010,AndrieuDoucet2010}. +However, these models are less useful +for change-point detection or other forms of discontinuous behavior +when the times of discontinuity are unknown. + +To remedy this deficiency, one can use a switching state-space +model as shown in \autoref{fig:switchss}. Here, we assume $S$ is a +hidden, discrete process with Markovian dynamics. Then, the value of +the hidden state at time $i$, $s_i=k$ say, can determine the evolution of +the continuous model at time $i$. The graphical model in +\autoref{fig:switchss} gives the conditional independence properties +we will use in our model for musical interpretation, but this +represents just one of many possibilities. Switching state-space models have a long +history with many applications from +economics~\citep{KimNelson1998,Kim1994,Hamilton2011} to speech +processing~\citep{FoxSudderth2011} to animal +movement~\citep{PattersonThomas2008,BlockJonsen2011}. An excellent +overview of the history, typography, and algorithmic developments can +be found in~\citep{GhahramaniHinton2000}. In Equation~\eqref{eq:lgmod}, the +parameter matrices were not time varying. In our switching model, we +allow the switch states $s_i, s_{i-1}$, along with the parameter +vector $\theta$, to determine the specific dynamics at time $i$: +\begin{equation} + \begin{aligned} + x_1 &\sim N(x_0,\ P_0),\\ + x_{i+1}&= d(s_i,s_{i-1})+T(s_i,s_{i-1}) x_i + \eta_i, + & \eta_i &\sim N(0,Q(s_i,s_{i-1})),\\ + y_i&= c(s_i) + Z(s_i) x_i + \epsilon_i, & \epsilon_i &\sim N(0, G(s_i)). + \end{aligned} +\end{equation} +In other words, the hidden Markov (switch) state determines which parameter +matrices govern the evolution of the system. + + + + + + +\begin{figure} + \centering + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex,ampersand replacement=\&] + % The various elements are conveniently placed using a matrix: + \matrix[row sep=1cm,column sep=1cm] { + % First line: Switch state + \node (s_k-2) {$\cdots$}; \& + \node (s_k-1) [switch]{$s_{i-1}$}; \& + \node (s_k) [switch]{$s_i$}; \& + \node (s_k+1) [switch]{$s_{i+1}$}; \& + \node (s_k+2) {$\cdots$}; + \\ + % Second line: hidden continuous state + \node (x_k-2) {$\cdots$}; \& + \node (x_k-1) [state] {$\mathbf{x}_{i-1}$}; \& + \node (x_k) [state] {$\mathbf{x}_i$}; \& + \node (x_k+1) [state] {$\mathbf{x}_{i+1}$}; \& + \node (x_k+2) {$\cdots$}; + \\ + % Third line: Measurement + \node (y_k-2) {$\cdots$}; \& + \node (y_k-1) [measurement] {$\mathbf{y}_{i-1}$}; \& + \node (y_k) [measurement] {$\mathbf{y}_i$}; \& + \node (y_k+1) [measurement] {$\mathbf{y}_{i+1}$}; \& + \node (y_k+2) {$\cdots$}; + \\ + }; + % The diagram elements are now connected through arrows: + \path[->] + (s_k-2) edge (s_k-1) + (s_k-1) edge (s_k) + (s_k) edge (s_k+1) + (s_k+1) edge (s_k+2) + + (x_k-2) edge (x_k-1) + (x_k-1) edge (x_k) + (x_k) edge (x_k+1) + (x_k+1) edge (x_k+2) + + (s_k-1) edge (x_k-1) + (s_k) edge (x_k) + (s_k+1) edge (x_k+1) + + (x_k-1) edge (y_k-1) + (x_k) edge (y_k) + (x_k+1) edge (y_k+1) + + (s_k-1) edge (x_k) + (s_k) edge (x_k+1) + (s_k+1) edge (x_k+2) + + (s_k-1) edge[bend left] (y_k-1) + (s_k) edge[bend left] (y_k) + (s_k+1) edge[bend left] (y_k+1) + ; + \end{tikzpicture} + \caption{Switching state space model. Filled objects are observed, + rectangles are discrete, and circles are continuous.\label{fig:switchss}} +\end{figure} + + + + + + +\subsection{A model for tempo decisions} + + +In musical scores, {\em tempi} (the Italian plural of tempo) may be +marked at various points throughout a piece of music. The +beginning can be either explicit, with a metronome marking to +indicate the number of beats per minute (b.p.m.), and/or with some words +(e.g., {\em Adagio}, {\em Presto}, {\em Langsam}, Sprightly) which indicate an +approximate speed. +\begin{figure}[t!] + \centering + \includegraphics[height=3cm]{mazurka-top.pdf} + \includegraphics[height=3cm]{ballade-top.pdf} + \caption{The beginning of two Chopin piano compositions: the Mazurka + we analyze is on the left while the Ballade No.\ 1, Op.\ 23 is on + the right.} + \label{fig:tempo-markings} +\end{figure} +\autoref{fig:tempo-markings} shows the beginning of two Chopin piano +compositions: the Mazurka we analyze and the Ballade No.\ 1, Op.\ +23. The initial tempo of the Mazurka is given with a metronome +marking as well as the Italian phrase {\em Allegro ma non troppo} +(``cheerful, but not too much''). The beginning of the Ballade is +marked {\em Largo}, which translates literally as ``broad'' or +``wide'', and modified by the stylistic indication {\em pesante} +(``heavy''). Obviously, the metronome markings are much more exact, +though even these are often viewed as suggestions rather than +commandments. The metronome markings in most of Beethoven's +compositions, for example, are notoriously fast, and some scholars +believe that his metronome (one of the first ever made) was +inaccurate~\citep{ForsenGray2013}. Often, compositions will have numerous such markings later +in the piece of music, but these are only some of the ways that tempo +is indicated. Composers will also indicate periods of speeding-up +(\emph{accelerando}) or +slowing-down (\emph{ritardando}). + +Absent instructions from the composer, performers generally maintain +(or try to maintain) a steady tempo, and this assumption plays a major +role in our model of tempo decisions. Of course, a normal human +never plays precisely like a +metronome, although she may try quite hard to do so. The observed +ratio of musical time to clock time +is therefore best viewed as stochastic, the sum of an +intentional, constant tempo, plus noise representing inaccuracy +or, perhaps more charitably, unintentional variation which the +listener fails to perceive as ``wrong''. For instance, the example in +\autoref{fig:short-perf} shows the beginning of the piece as performed +by Arthur Rubinstein in a 1961 recording. +\begin{figure}[t!] + \centering + \includegraphics[width=.9\linewidth]{small-rubinstein-1961-1} + \caption{The solid line shows the observed note-by-note tempo for + the beginning of the Mazurka as performed by Arthur Rubinstein in + 1961. The dashed line indicates 132 b.p.m.} + \label{fig:short-perf} +\end{figure} +The solid line shows the +actual, performed tempo, while the dashed horizontal line is placed at +the indicated tempo of 132 b.p.m. The figure has three important +lessons: (1) observed speed varies around intended tempo; (2) 132 b.p.m.\ is +not necessarily the tempo a performer will choose despite the +indication; and (3) performers have other tempo intentions which are +not marked, like the pronounced slow-down in measures 7--8. + +Estimating intended {\em tempi} would be reasonably simple, perhaps, +if the locations of the tempo changes were known. In such a case, +the average of tempi between changes may be a good estimate as +could the slope of known speed-ups or slow-downs. However, performers +take liberties with these decisions, exactly the liberties we would +like to discover. This suggests employing a switching model with a +small number of discrete states. + +Similar to~\citet{GuRaphael2012}, we propose a Markov model for $S$ on four +states for four different performance behaviors +with transition probability +diagram given by \autoref{fig:transmat}. +\begin{figure}[tb!] + \centering + \tikzstyle{switch}=[rectangle, + thick, minimum size=1cm, draw=black] + \begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex] + \matrix[row sep=0.25cm,column sep=.5cm] { + \node (S4) [switch] {$4$}; &&&&& & \node (S22) [switch] {$2$};\\ + &\node (S1) [switch] {$1$}; &&&& \node (S2) [switch] {$2$}; \\ + \\ \\ \\ \\ \\ \\ + &\node (S3) [switch] {$3$};\\ + \node (S33) [switch] {$3$};\\ + }; + \path[->] + (S1) edge [bend left] (S4) + (S4) edge [bend left] (S1) + (S1) edge [bend left] node [above] {$p_{12}$}(S22) + (S22) edge (S2) + (S2) edge [bend left] (S33) + (S1) edge [bend right] node [left] {$p_{13}$}(S33) + (S33) edge (S3) + (S3) edge [bend right] node [right] {$p_{32}$}(S22) + (S3) edge [loop left](S3) + (S2) edge [loop above] node [left] {$p_{22}$}(S2) + (S3) edge node [left] {$p_{31}$}(S1) + (S2) edge node [above] {$p_{21}$}(S1); + \path[->] (S1) edge [out=300,in=330,looseness=8] node [below right] + {$p_{11}$} (S1); + \end{tikzpicture} + \caption{Transition diagram. The four states are: constant tempo + (1), deceleration (2), acceleration (3), and emphasis (4).\label{fig:transmat}} +\end{figure} +The 4 switch states correspond to 4 different behaviors for the +performer: (1) constant tempo, (2) speeding up, (3) slowing down, and +(4) single note stress. As shown in the diagram, we only allow certain +transitions for musical reasons and for estimability. The marked +transition probabilities are sufficient to infer the remainder. The fourth +state, stress, corresponds to {\em tenuto}, a common feature of +musical performance. Such stresses may be marked with a line over the +note in question, but are more often a feature of the performer taste, +corresponding to a longer-than-written duration of a particular +note. Such emphases occur for a variety of musical purposes---emphasis +of the beat in running notes, the top of a +phrase, a ``landing point'' where a phrase ends, etc.---but are always +within the frame of constant tempo. Thus we allow stress to occur only +after and before notes in state 1. Furthermore, we cannot allow +state 2 or state 3 to return immediately to state 1, or else ``stress'' could +happen through these pathways. We impose related constraints for a transition from state 2 +to state 3 and vice versa. Essentially, transitions into these states must remain +there before leaving. Thus, the entire transition diagram is +fully determined. This process can be viewed equivalently as a +second-order Markov chain. +% We discuss some potential improvements at the end +% of~\autoref{sec:analys-chop-mazurka}. + + +Our data gives $y_i$ as the observed tempo (in b.p.m.) of the note (or +chord) of the $i^{th}$ note onset in Chopin's Mazurka Op.\ 68 No.\ 3. The +hidden continuous variable ($X_i$) is +taken to be a two component vector with the first component being the +prevailing tempo and the second the amount of acceleration. The amount, or +existence, of acceleration is determined by the current and previous +switch states. We use $l_i$ to denote the musical duration of +a particular note as given by the written score, so, throughout this piece, a quarter-note (\quarternote) has $l_i=1/3$, an +eighth note (\eighthnote) has $l_i=1/6$, etc. This is because each +measure contains three quarter notes. In more complicated +music with changing time signatures or instances where the notation +doesn't necessarily correspond with the time signature, more care +would be required. The observed tempo is already normalized to account +for variable note durations, but the intentional tempo and its +variance should be proportional to $l_i$. When the performer is in state 1 (or +transits in and out of state 4), we take the prevailing tempo as +constant with no acceleration: $X_{i+1} = X_i$. +Corresponding to these configurations, the parameter +matrices are given in \autoref{tab:parmats} (transition equation) and +\autoref{tab:parmats2} (measurement equation). +\begin{table} +\centering +\begin{tabular}[h!]{@{}llcccc@{}} +\toprule +%&&&\multicolumn{3}{c}{Transition equation}\\ + \multicolumn{2}{c}{Switch states} &\phantom{a}& \multicolumn{3}{c}{parameter + matrices}\\ + \cmidrule{1-2} \cmidrule{4-6} + $s_i$ & $s_{i-1}$ && $d$ & $T$ & $Q$ \\ + \midrule + $1$ & $1$ && 0 & $\begin{pmatrix}1&0\\0&0\end{pmatrix}$ + & $\begin{pmatrix}0&0\\0&0\end{pmatrix}$\\ + $2$ & $1$ && $\begin{pmatrix} l_i\mu_{\textrm{acc}}\\ \mu_{\textrm{acc}}\end{pmatrix}$ + & $\begin{pmatrix} 1 & 0 \\ 0 & + 0 \end{pmatrix}$ + & $\sigma_{\textrm{acc}}^2\begin{pmatrix} l_i^2 & l_i\\ l_i & 1 \end{pmatrix}$\\ + $3$ & $1$ && $\begin{pmatrix} -l_i\mu_{\textrm{acc}}\\ -\mu_{\textrm{acc}}\end{pmatrix}$ + & $\begin{pmatrix} 1 & 0 \\ 0 & + 0 \end{pmatrix}$ + & $\sigma_{\textrm{acc}}^2\begin{pmatrix} l_i^2 & l_i\\ l_i & 1 \end{pmatrix}$\\ + $4$ & $1$ && $\begin{pmatrix}0\\\mu_{\textrm{stress}}\end{pmatrix}$ + & $\begin{pmatrix}1&0\\0&0\end{pmatrix}$ + & $\begin{pmatrix}0&0\\0&\sigma_{\textrm{stress}}^2\end{pmatrix}$\\ + $2$ & $2$ && 0 & $\begin{pmatrix} 1 & l_i \\ 0 & 1 \end{pmatrix}$ + & $\begin{pmatrix}0&0\\0&0\end{pmatrix}$\\ + $3$ & $2$ && $\begin{pmatrix} -l_i\mu_{\textrm{acc}}\\ -\mu_{\textrm{acc}}\end{pmatrix}$ + & $\begin{pmatrix} 1 & 0 \\ 0 & + 0 \end{pmatrix}$ + & $\sigma_{\textrm{acc}}^2\begin{pmatrix} l_i^2 & l_i\\ l_i & 1 \end{pmatrix}$\\ + $1$ & $2$ && $\begin{pmatrix} \mu_{\textrm{tempo}}\\0\end{pmatrix}$ & 0 + & $\begin{pmatrix} \sigma^2_{\textrm{tempo}} & 0\\ 0 & 0 \end{pmatrix}$\\ + $3$ & $3$ && 0& $\begin{pmatrix} 1 & l_i \\ 0 & 1 \end{pmatrix}$ + & $\begin{pmatrix}0&0\\0&0\end{pmatrix}$\\ +$2$ & $3$ && $\begin{pmatrix} l_i\mu_{\textrm{acc}}\\ \mu_{\textrm{acc}}\end{pmatrix}$ + & $\begin{pmatrix} 1 & 0 \\ 0 & + 0 \end{pmatrix}$ + & $\sigma_{\textrm{acc}}^2\begin{pmatrix} l_i^2 & l_i\\ l_i & 1 \end{pmatrix}$\\ + $1$ & $3$ && $\begin{pmatrix} \mu_{\textrm{tempo}}\\0\end{pmatrix}$ & 0 + & $\begin{pmatrix} \sigma^2_{\textrm{tempo}} & 0\\ 0 & 0 \end{pmatrix}$\\ + $1$ & $4$ && 0 & $\begin{pmatrix}1&0\\0&0\end{pmatrix}$ + & $\begin{pmatrix}0&0\\0&0\end{pmatrix}$\\ + \bottomrule +\end{tabular} +\caption{Parameter matrices of the transition equation for the switching state space model.\label{tab:parmats}} +\end{table} +% +% +\begin{table} +\centering +\begin{tabular}[h!]{@{}llcccc@{}} +\toprule +%&&&\multicolumn{3}{c}{Measurement equation}\\ + \multicolumn{2}{c}{Switch states} &\phantom{a}& \multicolumn{3}{c}{parameter + matrices}\\ + \cmidrule{1-2} \cmidrule{4-6} + $s_i$ &&& $c$ & $Z$ & $G$\\ + \midrule + $4$ & && 0 & $\begin{pmatrix} 1 & 1 \end{pmatrix}$ & + $\sigma^2_\epsilon$\\ + else &&& 0 & $\begin{pmatrix} 1 & 0 \end{pmatrix}$ & + $\sigma^2_\epsilon$\\ +\bottomrule +\end{tabular} +\caption{Parameter matrices of the measurement equation for the switching state space model.\label{tab:parmats2}} +\end{table} +So for any performance, we want to be able to estimate +the following parameters: $\sigma_{\textrm{tempo}}^2$, $\sigma_{\textrm{acc}}^2$, $\sigma^2_{\textrm{stress}}$, +$\sigma_\epsilon^2$, the probabilities of the transition matrix (there +are 7), and means $\mu_{\textrm{tempo}}$, $\mu_{\textrm{acc}}$, and $\mu_{\textrm{stress}}$. Lastly, we have the initial state distribution +\[ +x_1\sim N\left( \begin{pmatrix}\mu_1\\0\end{pmatrix} + ,\ \begin{pmatrix} \sigma^2_1 & 0\\0 & 0 + \end{pmatrix}\right)\; \; \textrm{where} \; \; s_1=1. +\] + +To clarify this model, we explicate two different behaviors: discrete +sequence $1\rightarrow 4\rightarrow 1$ (emphasis within constant tempo) and discrete sequence +$1\rightarrow 1\rightarrow 2$ (constant tempo to slowing down). In the +first case, the state space system has the following configurations +{\footnotesize +\begin{align*} + 1\rightarrow 4 && 4\rightarrow 1\\ + x_{2} &= \begin{pmatrix} 0\\ \mu_{\textrm{stress}} \end{pmatrix} + + \begin{pmatrix}1&0\\0&0\end{pmatrix} x_{1} + + \mbox{N}\left(0,\ \begin{pmatrix}0&0\\0&\sigma_{\textrm{stress}}^2\end{pmatrix}\right) + & x_{3} + &= + \begin{pmatrix}1&0\\0&0\end{pmatrix} x_{2} \\ + y_2 &= (1\quad 1) x_2 + \mbox{N}(0,\ + \sigma_\epsilon^2) & +y_3 &= (1\quad 0) x_3 + \mbox{N}(0,\ + \sigma_\epsilon^2), +\end{align*} +}% +while in the second +{\footnotesize +\begin{align*} + 1\rightarrow 1 && 1\rightarrow 2\\ + x_{2} &= + \begin{pmatrix}1&0\\0&0\end{pmatrix} x_{1} + & x_{3} + &= \begin{pmatrix} l_i\mu_{\textrm{acc}}\\ \mu_{\textrm{acc}}\end{pmatrix} + + \begin{pmatrix}1&0\\0&0\end{pmatrix} x_{1} + + \mbox{N}\left(0,\ \sigma_{\textrm{acc}}^2\begin{pmatrix} l_i^2 & l_i\\ l_i & 1 \end{pmatrix}\right)\\ + y_2 &= (1\quad 0) x_2 + \mbox{N}(0,\ + \sigma_\epsilon^2) & +y_3 &= (1\quad 0) x_3 + \mbox{N}(0,\ + \sigma_\epsilon^2). +\end{align*} +}% +Recall that in any case $y_i$ is a scalar and $x_i \in \mathbb{R}^2$. + + +\subsection{Estimation and computational issues} +\label{sec:computational-issues} + +To understand the performance decisions of individual musicians, we +wish to simultaneously learn $\theta$, $S$, and $X$. Because the +switch states $S$ and the continuous states $X$ are both hidden, this becomes +an NP-hard problem. In particular, there are $4^n$ possible paths +through the switch variables, so evaluating the likelihood to maximize +over $\theta$ via the Kalman filter at each path is intractable. +\citet{GhahramaniHinton2000} give a variational approximation to +estimate $\theta$ without also estimating $S$, but, as our goal is to +learn both, we use the particle filtering approximation described by +\citet{FearnheadClifford2003}. ~\cite{WhiteleyAndrieu2010} refer to +this algorithm as the Discrete Particle Filter, and it can be seen as +an instance of the ``Beam Search'' optimization +technique~\citep{Bisiani1992}. The details are given in +\autoref{alg:dpf} but the intuition is as follows: (1) for the first +few time points, evaluate +one step of the Kalman filter for each possible subsequent discrete +state and store all these values; (2) calculate weights for each path +by updating previous weights with the likelihood multiplied by the transition probability; +(3) continue through time until the number of stored values exceeds +some threshold storage limit; (4) from that point forward, subselect +the ``best'' paths using a sampling scheme. +\begin{algorithm}[t!] + \caption{Discrete particle filter\label{alg:dpf}} + \begin{algorithmic}[1] + \STATE {\bfseries Input:} + $Y$, $\theta$, $\pi_1$ probability vector over initial states + (paths), $B$ maximum beam width + \FOR{$i=1$ {\bfseries to} $n$} + \STATE Set $b_i=|\{\pi_i>0\}|$, the number of current paths + \STATE Use %\autoref{alg:kalman} + the Kalman filter to calculate the 1-step likelihood + $\ell_i$ for each path and every potential state $s_{i+1}$ resulting in $b_i|S|$ particles + \STATE Set $\pi_{i+1} \leftarrow \pi_i\ell_i p_i$: multiply the path + probability by the likelihood and the probability of + transitioning. Normalize $\pi$. + \STATE Set $b_{i+1}=|\{\pi_{i+1}>0\}|$ . If $b_{i+1} > B$, resample the + weights to get $B$ non-zero weights and renormalize + \ENDFOR + \STATE Return $B$ paths $\{S_b\}_{b=1}^B$ along with their weights $\pi_{n}$. +\end{algorithmic} +\end{algorithm} +These paths can be +selected greedily, retaining only the highest values to that point, +though we use the resampling procedure of +\citep{FearnheadClifford2003} which is designed to +approximate to the full discrete distribution over paths with a subset +of support points by minimizing the mean squared +error. + +\autoref{alg:dpf} returns $B$ paths along with their weights through +the discrete state $S$ for a +particular parameter value $\theta$. One +can view this as a (approximate) distribution over paths conditional +on $\theta$. Instead, we will simply take the path with the highest +weight for inference via penalized maximum likelihood. Thus, the +likelihood of a particular parameter vector $\theta$ is evaluated by +computing the best path with \autoref{alg:dpf} and then using the best +path with the Kalman filter.%\autoref{alg:kalman}. + +\subsection{Penalized maximum likelihood} +\label{sec:penal-maxim-likel} + +Even without the latent discrete states, parameter estimation in +state-space models is a difficult problem, often plagued by spurious +local minima and non-identifiability. The addition of discrete states +only exacerbates this issue. However, for the present application, we +have reasonably strong prior information for many of the +parameters. The three mean parameters $\mu_{\textrm{tempo}}$, +$\mu_{\textrm{acc}}$ and $\mu_{\textrm{stress}}$ have sign +restrictions in addition to strong information about their magnitude: +average tempo should be around the indicated 132 b.p.m., the average +amount of acceleration should probably be less than the size of a +stress. We also have reasonably strong information about the +probabilities of transitioning between states: self-transitions should +be reasonably likely, long periods of speeding up are less likely than +long periods of slowing down which are less likely than long periods +in the constant tempo state. Because of this information, we use +informative priors as penalties on all the parameters we +estimate. This has the effect of introducing extra curvature to the +optimization problem as well as conforming with musical intuition. The +specific choices are shown in \autoref{tab:priors}. +\begin{table}[t] + \centering + \begin{tabular}{@{}rcll@{}} + \toprule + Parameter & \phantom{a} & Distribution & Prior mean\\ + \midrule + $\sigma^2_{\epsilon}$ & $\sim$ & Gamma$(40,\ 10)$ & 400 b.p.m.$^2$\\ + $\mu_{\textrm{tempo}}$ & $\sim$ & Gamma$(\overline{Y}^2/100,\ 100 + /\overline{Y})$ & $\overline{Y}$ + b.p.m.\\ + $-\mu_{\textrm{acc}} $ & $\sim$ & Gamma$(15,\ 2/3)$ & 10 b.p.m.\\ + $-\mu_{\textrm{stress}} $ & $\sim$ & Gamma$(20,\ 2)$ & 40 b.p.m.\\ + $\sigma^2_{\textrm{tempo}} $ & $\sim$ & Gamma$(40,\ 10)$ & 400 + b.p.m.$^2$\\ + $\sigma^2_{\textrm{acc}} $ & $=$ & 1 & 1 b.p.m.$^2$\\ + $\sigma^2_{\textrm{stress}} $ & $=$ & 1 & 1 b.p.m.$^2$\\ + $p_{1,\cdot}$ & $\sim$ & Dirichlet$(85,\ 5,\ 2,\ 8)$ \\ + $p_{2,\cdot}$ & $\sim$ & Dirichlet$(4,\ 10,\ 1,\ 0)$ \\ + $p_{3,\cdot}$ & $\sim$ & Dirichlet$(5,\ 3,\ 7,\ 0)$ \\ + \bottomrule + \end{tabular} + \caption{Informative prior distributions for the music model} + \label{tab:priors} +\end{table} +We fix $\sigma^2_{\textrm{acc}}$ and $\sigma^2_{\textrm{stress}}$ after numerical experiments suggested +that they were poorly identified. + +\subsection{Is this model reasonable?} + +It is reasonable to ask whether a simple model such as this is able to +accurately represent performance practice without removing musically important +information. In a statistical sense, this question is similar to the +problem of tuning parameter selection in nonparametric +estimation. Specifically, we do not want this model to +``over-smooth'' the performance, eliminating information necessary for +listener appreciation. One way to examine such a question +is to generate a performance using the smoothed tempos learned by +the model and compare it aurally with the original recording. +\citet{GuRaphael2012} used a model similar to ours to investigate just +this question. In one study, they surveyed nine graduate piano majors at a +major conservatory on twelve different piano excerpts. The pianists +were not meaningfully able to distinguish between the synthesized and +real recordings in the majority of experiments. Our model is more +expressive than that employed in the study, and the parameters are +estimated from data rather than calibrated. We expect that a similar +study with our model would yield similar, if not better, results. + + +\section{Analysis of Chopin's Mazurka Op.\ 68 No.\ 3} +\label{sec:analys-chop-mazurka} + +We use the model and procedures developed above to estimate the +parameters and performance choices for all 46 recordings of Chopin's +Mazurka. Here we describe the inferences our model allows on some +representative performances, describe parametric clusters determined +by our model, contrast these with some alternative approaches to music +modelling, and discuss some difficulties we encountered. All simulations and empirical calculations were performed with +\texttt{R}~\citep{R-Core-Team2019} and C++ via \texttt{Rcpp}~\citep{Eddelbuettel2013}. Figures and tables are generated +using the \texttt{tidyverse} family of +packages~\citep{Wickham2017, Wickham2016}. Dendrograms combined with +heatmaps for the proximity matrices were created with the +\texttt{heatmaply} package~\citep{GaliliOCallaghan2017}. +% The Supplemental Materials were created +% with \texttt{knitr} and +% \texttt{rmarkdown}~\citep{Xie2019,XieAllaire2018,Xie2015}. +Most +computations were implemented in parallel on a +% the Carbonate\footnote{This research was supported in part by Lilly +% Endowment, Inc., through its support for the Indiana University +% Pervasive Technology Institute.} +large +memory computer cluster via +the \texttt{batchtools} package~\citep{LangBischl2017}. + +\subsection{Musical analysis} +\label{sec:musical-analysis} + +Throughout his life, Fr\'ed\'eric Chopin composed dozens of Mazurkas, +of which 58 have been published. Inspired by a traditional Polish +dance, these pieces gave Chopin an idiomatic style upon which to +elaborate a wide variety of different compositional techniques, a +practice German and Italian composers had employed frequently over the previous 3 +centuries~\citep{BurkholderGrout2014}. Repetition of themes, figures, or even small motives plays +a central role in both the traditional dance and Chopin's compositions +as do particular rhythmic gestures~\citep{Kallberg1996}, especially the +dotted-eighth sixteenth note pattern on the first beat of a measure. + +Chopin's Op.\ 68 Mazurkas are a set of four similar works, published +posthumously in 1855. The Op.\ 68 No.\ 3, which we analyze here, was +composed in 1830, when Chopin was 20 years old. Around this time, +Chopin, already a piano virtuoso and accomplished composer, left his +native Warsaw and settled in Paris, where we would remain until his +death in 1849. + +This Mazurka has a rather simplistic ternary structure with two outer +sections and a contrasting middle (ABA). The first A section is made +up of four eight-bar phrases ($aaba$). The first phrase is echoed by the +second phrase: they are nearly identical, with the two exceptions +being that (1) the +second is marked {\em piano} (soft) rather {\em forte} (strong) and (2) +the second ends on the tonic (F major) rather than the dominant +(C major). The fourth eight-bar phrase is an exact repetition of the +second. The second A section is a repeat of the first two +eight-bar phrases of the beginning. The intervening B section is 12 +bars long, divided into three four-bar groups. The first four bars are +simply a repeated interval of a perfect $5^{th}$ in the left +hand. This {\em ostinato} will continue for the whole section. The remaining +eight measures consist of a four-bar phrase in the right hand repeated twice. The second differs from the first only on the final two notes, preparing the +recapitulation of the A section. + +In terms of tempi, the B section is indicated to be faster, with the +marking {\em Poco pi\`u vivo} (a little livelier). The B section ends +with a {\em ritardando} into the following A section. The $b$ section ends +with a {\em fermata} in measure 24, indicating an arbitrary +elongation while the piece +concludes with a two-measure long {\em ritardando}. Throughout, +frequent markings prescribe emphasis of the third beat of each measure. This +emphasis is in keeping with the mazurka style, an intentional +thwarting of the listener's expectation of first-beat emphasis. + +\autoref{fig:mazurka-10} shows the first ten measures of the musical +score with annotations for the sections discussed above and the +harmonic progression in Roman numerals below the staff. +\begin{figure}[t] + \centering + \includegraphics[width=.9\textwidth]{mazurka-first-10} + \caption{The first ten measures of Chopin's Mazurka Op.\ 68, No.\ + 3. The harmonic progression is indicated below the staff in Roman + numerals. Sections are marked above the staff, e.g., A + (a). Analysis by the authors. This image comes from the complete + score published by Bote and Bock in 1880. This composition is in + the public domain, and the score is freely available via the + International Music Score Library Project.} + \label{fig:mazurka-10} +\end{figure} +The harmonies are standard, in fact, they are essentially the same as +those of Pachelbel's {\em Canon}, familiar to many as ``that song +played at weddings.'' These harmonies, combined with the +rhythmic repetition suggests a further division of this and +all analogous sections into three small groupings: two two-measure +phrases, followed by a four-measure phrase. + +As a performer, these harmonic, rhythmic, and structural analyses aid +in interpretation. The performer needs to decide how to emphasize or +deemphasize these demarcations with slight or overt tempo or dynamic +alterations. In a live performance, she could use physical motion to +further suggest a particular interpretation. She can choose to +emphasize long phrases, in this +case, phrases of eight measures, or the shorter sub-phrases. Because +of the repetition of similar phrases, she may choose to emphasize the +long phrase on the first occurrence and shorter sub-phrases later on +for variety, for example. While the musical structure suggests such +possible interpretations, the performer must make these choices on +their own, and may even alter those decisions from performance to +performance. + + + +\subsection{Archetypal performances} +\label{sec:arch-perf} + + +\begin{figure}[t] + \centering + \includegraphics[width=.9\textwidth]{two-performances-1} + \caption{Inferred performer choices for two recordings. } + \label{fig:archetypal} +\end{figure} +Here we will carefully investigate how our model learns interpretive +decisions for three rather different performances. \autoref{fig:archetypal} shows the inferred state sequence for +recordings made by Joyce Hatto in 1993 and Sviatislav Richter in +1976. The B section is +shaded in gray to better illustrate the formal divisions discussed above. + +In terms of our model, these two performers are quite different +from each other. Hatto maintains a constant tempo carefully, remaining +in state 1 with the exception of four periods of deceleration. All +four periods coincide with the most significant phrase endings: at the +end of the A section at measure 32, the end of the B section at +measure 48, at the end of the piece, and the minor transition from +$b\rightarrow a$ in the first A section (measure 24). According +to our inferred model, she never accelerates or uses the transitory +stress state. + +In contrast, Richter uses all four states from our model. The short +blips of acceleration before the B section and before the +$b \rightarrow a$ transition are slightly out of place, and are +likely better labelled as ``constant'', but these state transitions +describe more severe decelerations than the model's linear +assumption would allow. Richter uses stress frequently. Some may well be +attributable to larger variance around constant tempo (picked up as +frequent stress rather than larger $\sigma^2_\epsilon$), but most +correspond to interesting note emphases, for example the second beat +of measure 20. This note is essentially a minor phrase ending, but is +also marked in the score with a {\em sforzando} (with sudden +emphasis). It's the first of two such occurrences in the piece, the +second coming four measures later on the {\em fermata}, Richter's slowest +note in the entire piece. Richter likely chooses to make this +prescribed emphasis with a sudden slow down in part because it takes +place within the context of an already loud passage, precluding the +use of extra volume. +\begin{table}[tb] + \centering + \caption{The estimated parameters for performances by Richter and + Hatto.} + \resizebox{\linewidth}{!}{% + \begin{tabular}{@{}lrrrrrrrrrrrr@{}} + \toprule + & $\sigma^2_\epsilon$ & $\mu_{\textrm{tempo}}$ + & $\mu_{\textrm{acc}}$ & $\mu_{\textrm{stress}}$ + & $\sigma^2_{\textrm{tempo}}$ & $p_{11}$ & $p_{12}$ & $p_{22}$ + & $p_{31}$ & $p_{13}$ & $p_{21}$ & $p_{32}$\\ + \midrule + Richter 1976 & 426.70 & 136.33 & -11.84 & -34.82 & 439.38 + & 0.85 & 0.05 & 0.74 & 0.44 & 0.02 & 0.25 & 0.17\\ + Hatto 1993 & 405.57 & 130.36 & -13.57 & -27.93 & 408.99 + & 0.94 & 0.03 & 0.82 & 0.36 & 0.01 & + 0.16 & 0.19\\ + Cortot 1951 & 403.71 & 182.84 & -21.43 & -45.67 + & 460.82 & 0.92 & 0.02 & 0.71 & 0.34 & 0.03 & 0.23 & 0.09\\ + \bottomrule + \end{tabular} +} +\label{tab:two-perf-parm} +\end{table} +\autoref{tab:two-perf-parm} shows the estimated parameters for these +two performances. Richter has larger observation variance, +$\sigma^2_{\epsilon}$, slightly faster average tempo, lower +acceleration, and larger stress. He also has a larger tempo variance, +meaning that returns to state 1 can start at relatively different +tempos. On the other hand, Hatto is much more +likely to remain in states 1 or 2. These inferences are largely +consistent with the visual takeaways of \autoref{fig:archetypal}. It's +easy to see the increased variability around the constant tempo in +Richter's performance and the faster overall tempos in both the A and +B sections. +% +While these two performances are quite different from each other, they +also display similarities. Both take a faster tempo in the B +section versus the A sections. Both performers slow down at the end of +the piece, at the end of the B section, immediately preceding the B section, and at the +$b\rightarrow a$ transition. + +Alfred Cortot's 1951 performance is displayed +in~\autoref{fig:cortot}. Both in terms of the parametric model we +propose, and if we simply compare the vectors of note-by-note tempos +(discussed in more detail below), this performance is an +outlier. Cortot never uses the deceleration state, and he remains in +constant tempo for the entirety of both A sections. While the model +describes his performance well, it also illustrates a deficiency of +this approach: Cortot, more than any other performer, has large +contrasts between the A and B sections. His A section is the slowest +of all 46 recordings at around 64 b.p.m., half the marked +tempo. The next slowest is Maryla Jonas's recording at around 84 +b.p.m. Meanwhile, his B section is among the fastest of all the +recordings and contains the fastest individual note. Additionally, +there is stunningly little tempo variability in his A sections, but +dramatic variation in the B section coupled with frequent uses of the +acceleration and emphasis states. Taken together, Cortot's performance +may be better described by estimating our model separately on the two sections. +\begin{figure}[t] + \centering + \includegraphics[width=.9\textwidth]{cortot-performance-1} + \caption{Inferred performance choices for Alfred Cortot's 1951 + recording.} + \label{fig:cortot} +\end{figure} + + + +\subsection{Clustering musical performances} +\label{sec:clust-music-perf} + +To better understand how all the 46 performances relate to each other, +we applied parametric clustering using the eleven-dimensional vector +of estimated parameters. Because the estimated parameters are of +different scales, have different domains, and can covary, we treat +them differentially. To calculate distances between the mean and +variance parameters, $\sigma^2_\epsilon$, $\mu_{\textrm{tempo}}$, +$\mu_{\textrm{acc}}$, $\mu_{\textrm{stress}}$, and +$\sigma^2_{\textrm{tempo}}$ we simply use Euclidean distance on each +individually. In the cases of the probabilities, we use weighted +Euclidean distance in the prior precision. For example, for +$p_{1\cdot}$, we calculate +\begin{equation} +d\left(p_{1\cdot},\ p'_{1\cdot}\right) = (p_{1\cdot}-p'_{1\cdot})^\top + \Omega (p_{1\cdot}-p'_{1\cdot}),\quad +\textrm{where} + \quad\Omega^{-1}_{ij} := \Sigma_{ij} := + \alpha_0^{-2}(\alpha_0+1)^{-1}\left(\alpha_i\alpha_0 \delta_{ij} + - \alpha_i\alpha_j\right), +\end{equation} +is the covariance matrix of the Dirichlet distribution with +$\alpha_0=\sum_i\alpha_i$ and $\delta_{ij}$ the indicator that +$i=j$. We then standardize each individual distance matrix to have a +maximum distance of 1 and add them together so that the maximum distance +between performances is 8. + + +\begin{figure}[t] + \centering + \includegraphics[width=.45\linewidth]{parametric-clusters-1} + \includegraphics[width=.45\linewidth]{parametric-clusters-2} + \caption{Distance matrix using estimated model parameters. Left: the + matrix for all 46 parameters. Right: The same matrix with + ``outlying'' performances removed and a dendrogram from hierarchical + clustering.} + \label{fig:dmats} +\end{figure} +\autoref{fig:dmats} shows the distance matrix calculated from the +estimated parameters for all 46 performances (left) and the same +matrix with ``outlying'' performances removed (right). To determine +outlying performances, we calculated the distance to the third nearest +performance. We then removed those performances that exceeded a +threshold, meaning that the nearest similar performances were ``far +away''. This screening left 25 performances. We used hierarchical +clustering on these 25 performances, trying between two and five +clusters. The remaining 21 were grouped together as ``other''. The +right panel of \autoref{fig:dmats} displays this subset along with a +dendrogram and four clusters. + +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{clust-densities-sub2-1} + \caption{Cluster densities for Markov transition probabilities.} + \label{fig:clust-density-tp} +\end{figure} +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{clust-densities-sub1-1} + \caption{Cluster densities for mean and variance parameters.} + \label{fig:clust-density-mv} +\end{figure} +The first cluster corresponds to performances which are reasonably +staid. The emphasis state is rarely visited with the performer tending +to stay in the constant tempo state with periods of slowing down at +the ends of phrases. Acceleration is never used. Such state +preferences are clearly inferred by the model as shown in the +top row of \autoref{fig:clust-density-tp}. Furthermore, these +performances have relatively low average tempos, and not much +difference between the A and B sections. Joyce Hatto's performance +shown in \autoref{fig:archetypal} is typical of this cluster. + +Recordings in the second +cluster tend to transition quickly between states, especially constant +tempo and slowing down accompanied by frequent transitory +emphases. The probability of remaining in state 1 is the lowest while +the probability of entering state 2 from state 1 is +the highest. The acceleration state is rarely visited. Four of +the most similar performances are in this cluster, shown in +\autoref{fig:similar}, along with Richter's 1976 recording. +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{similar-perfs-1} + \caption{Four similar performances, all in the second cluster.} + \label{fig:similar} +\end{figure} + +Cluster three is somewhat like cluster one in that performers tend to +stay in state 1 for long periods of time, but they transition more +quickly from state 3 back to state 1. They also use state 4 frequently +whereas cluster one +did not. They tend to have very large tempo +contrasts between the A and B sections. +Cluster four has both faster average tempos and more variability from one period of +constant tempo to the next. State 4 is rare, instead using constant tempo +states that persist for small amounts of time to reflect note +emphases. + +% \begin{figure}[t] +% \centering +% \includegraphics[width=.45\linewidth]{raw-data-clusters-1} +% \caption{Distance matrix and dendrogram calculated using the +% note-by-note tempo vector for each recording.} +% \label{fig:raw-data-clusters} +% \end{figure} +Comparing our clusters to those we would find from simply clustering +the distances between note-by-note tempo vectors reveals a number of +differences (see the Supplement for the distance matrix calculated in +this way). The four recordings in \autoref{fig:similar} would be +spread across three different clusters, for example, as would our +cluster one. On the other hand, both metrics see Cortot's recording as a +strong outlier, and clustering by tempo vectors often (somewhat +miraculously) groups recordings by the same pianist together: both +recordings by Smidowicz, three of the four recordings by Rubinstein, +both recordings by Hatto. +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{rubinstein-perfs-1} + \caption{The four recordings by Arthur Rubinstein. Our clustering + puts the 1952 and 1961 recordings in clusters one and two while + leaving the others out. Clustering by tempo vector separates 1952 + from the other three.} + \label{fig:rubinstein} +\end{figure} +\autoref{fig:rubinstein} shows all four Rubinstein recordings. The +1939 recording is rather odd in that the measures 24--32 are so slow +relative to the rest of the A section. The variability in the 1966 +recording nearly obscures the contrast between the B section and the +surrounding A sections. These two recordings are nonetheless clustered +together by the tempo vectors. Our method on the other hand, puts both +in the ``other'' grouping. The estimated parameters for these four +performances are shown in the bottom half of +\autoref{tab:similar-different-perf}. The top half shows the +parameters for the four similar performances in +\autoref{fig:similar}. There is much larger variability across +Rubinstein's recordings, as we would expect. +\begin{table}[tb] + \centering + \caption{The estimated parameters for the four similar performances + in Cluster Two and those for all four by Arthur Rubinstein. + \label{tab:similar-different-perf}} + \resizebox{\linewidth}{!}{% + \begin{tabular}{@{}lrrrrrrrrrrrr@{}} + \toprule + & $\sigma^2_\epsilon$ & $\mu_{\textrm{tempo}}$ + & $\mu_{\textrm{acc}}$ & $\mu_{\textrm{stress}}$ + & $\sigma^2_{\textrm{tempo}}$ & $p_{11}$ & $p_{12}$ & $p_{22}$ + & $p_{31}$ & $p_{13}$ & $p_{21}$ & $p_{32}$\\ + \midrule + Wasowski 1980 & 414.99 & 132.00 & -10.00 & -40.00 + & 425.00 & 0.85 & 0.05 & 0.67 & 0.34 & 0.02 & 0.26 & 0.20\\ + Shebanova 2002 & 439.98 & 132.00 & -10.00 & -40.00 + & 400.02 & 0.85 & 0.05 & 0.67 & 0.33 & 0.02 & 0.27 & 0.20\\ + Luisada 1991 & 494.33 & 127.80 & -10.24 & -32.56 + & 411.63 & 0.84 & 0.10 & 0.71 & 0.35 & 0.01 & 0.26 & 0.19\\ + Milkina 1970 & 435.25 & 136.38 & -9.68 & -40.02 & 400.01 + & 0.87 & 0.05 & 0.68 & 0.33 & 0.02 & + 0.26 & 0.21\\ + \midrule + Rubinstein 1939 & 520.32 & 145.26 & -7.89 & -50.82 + & 345.64 & 0.89 & 0.02 & 0.83 & 0.56 & 0.05 & 0.13 & 0.16\\ + Rubinstein 1952 & 481.13 & 128.13 & -7.76 & -17.59 + & 409.30 & 0.93 & 0.04 & 0.68 & 0.32 & 0.01 & 0.28 & 0.19\\ + Rubinstein 1961 & 434.23 & 139.17 & -8.34 & -35.08 + & 355.00 & 0.90 & 0.06 & 0.56 & 0.46 & 0.01 & 0.41 & 0.19\\ + Rubinstein 1966 & 380.95 & 127.24 & -8.80 & -42.28 + & 473.69 & 0.87 & 0.07 & 0.36 & 0.34 & 0.01 & 0.61 & 0.20\\ + \bottomrule + \end{tabular} + } +\end{table} + + +\subsection{Alternative smoothers} +\label{sec:altern-smooth} + +Our model is just one type of smoothing one could imagine using to +find low-dimensional structure for the vector of note-by-note +tempos. Alternative statistical techniques are common, and examining +how they compare with our method helps to illuminate some of its +benefits. The most obvious alternative is to use smoothing +splines~\citep{CravenWahba1978,Wahba1990} though total-variation +denoising or trend filtering \citep{KimKoh2009,Tibshirani2014} are +other reasonable alternatives. +These statistical techniques perform smoothing by encouraging small +changes in derivatives (smoothing splines) or bounded total variation +(trend filtering). +But musical performances do not conform to these assumptions because tempo interpretations rely on the juxtaposition of local smoothness +with sudden changes and emphases to create listener interest. It is +exactly the parts of a performance that are poorly described by +statistical smoothers that render a performance +interesting. Furthermore, many of these +inflections are notated by the +composer or are implicit in performance practice developed over +centuries of musical expressivity. Consequently, smoothing that +incorporates domain knowledge leads to better statistical and +empirical results. +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{alternative-smoothers-1} + \caption{Smoothing with splines and musical models} + \label{fig:splines} +\end{figure} + +\autoref{fig:splines} +shows the note-by-note tempo of Richter's 1976 recording. Splines with +equally spaced knots are shown in yellow. We use generalized cross +validation~\citep{GolubHeath1979} to select the number of knots (one +knot per measure). The red line shows a regression spline fewer knots, +but whose locations were chosen +manually +to coincide with the musical phrase endings discussed in +\autoref{sec:musical-analysis}. Knots at phrase endings were +duplicated up to four times to allow for discontinuities. The blue line +shows the estimated smooth tempo from our model (the same as in +\autoref{fig:archetypal}). The regression spline with +equally spaced knots undersmooths in constant tempo areas in an +attempt to capture sudden emphases and dramatic changes in others. The spline +with informed knot choice does much better, picking up the periods of +deceleration at the ends of phrases. Our model learns these behaviors +on its own while also capturing individual emphases that are missed in +the musical analysis but are idiosyncratic to Richter's playing. It is +also more parsimonious to musical interpretation, inferring constant +tempo periods rather than resulting in smoothly varying tempos in +stable periods.%, such as measures 1--16. + +\subsection{Problems with the model and estimation} +\label{sec:problems-with-model} + +While our model of musical decision making yields interesting insights +into performance practice most of the time, it also suffers from some +deficiencies. As discussed above in reference to Alfred Cortot's +recording, the assumption that all parameters are stable over the +entire piece may not always be accurate. The $\mu_{\textrm{tempo}}$ +parameter especially, should be estimated separately in different +sections. This problem will only be compounded in more complex music +with many contrasting sections. A related issue is the current form +for the slowing down and speeding up sections. Our model assumes that +both occur linearly, with a constant decrease of $\mu_{\textrm{acc}}$ +b.p.m. An ability to slow increasingly as one remains in the state may +improve the model fit. + +There is nothing intrinsic to the model which forces states 2, +3, or 4 to always go in the correct direction. If for example, +$\mu_{\textrm{acc}}$ is small in magnitude relative to +$\sigma^2_{\textrm{acc}}$, an acceleration could be learned as time +spent in state 2 but with large positive errors. For this piece, the +penalties help to avoid such occurrences, but this aspect of the +Gaussian state-space model could be improved by enforcing non-Gaussian +behavior. Or course, such constraints would complicate likelihood +evaluation since the Kalman filter could no longer be used. Relatedly, +our model produced objectively incorrect inferences on two performances +\begin{figure}[t] + \centering + \includegraphics[width=.9\linewidth]{bad-model-1} + \caption{Estimation errors on two performances.} + \label{fig:bad-model} +\end{figure} +(\autoref{fig:bad-model}). Here, the estimated +path failed to transition to state 1 at the +recapitulation of the A section. In both cases, the resulting path +stands out dramatically, remaining in the much faster constant tempo +state from the B section with overly frequent emphases. Both of these +performances are quite volatile, making estimation difficult, and were clustered as ``other''. + +% One issue in our model that the effect of states two and three can be flipped. If $\tau_t$ is small enough, and $\sigma_4^2$ and $\sigma_2^2$ are large enough, it would be possible to get a negative number for the acceleration term when in state 2 or a positive number when in state three and still get a reasonably high likelihood. This could be fixed by adding a constraint on the ratio of the $\tau_t$ and $\sigma$'s 2 and 4. + +\section{Discussion} +\label{sec:discussion} + + +Musical interpretation is the most important factor +in determining whether or not concertgoers enjoy a classical performance. Every +performance includes mistakes---intonation issues, a lost note, an +unpleasant sound---but these are all easily forgotten (or unnoticed) when a performer +engages her audience, imbuing a piece with novel emotional content +beyond the vague instructions inscribed on the printed page. While music teachers use +imagery or heuristic guidelines to motivate interpretive decisions, combining these +vague instructions to create a convincing performance remains the domain +of the performer, subject to the whims of the moment, technical +fluency, and taste. + +In this paper, we develop a statistical model for tempo to elucidate performance +decisions from classical music recordings. We present an algorithm for +performing likelihood inference, estimate our model using a large +collection of recordings of the same composition, and demonstrate how +the model is able to recover performer intentions, and how they relate +to standard musical analysis. While our methods perform well, our +analysis reveals a number of avenues for future work an +improvement. For the piano, apart from tempo decisions, the performer +can also control dynamics differentially. Similar techniques to those +employed here could be used to describe levels of loudness, and +creating a model that combined both is desirable. Pianists have +relatively few variables under their control for interpretation: +tempo, dynamics, and pedalling. On the other had, string players have +many more. Bowing decisions, fingerings, vibrato, broken chords are +all important tools which are difficult to learn from a recording, let +alone describe with a simple statistical model. Significant work would +be required to generalize our techniques to more detailed +interpretative analysis. On the other hand, focusing simply on tempo +can be useful with solo performances or with larger +ensembles. Examining more complex genres---sonatas, string quartets, +symphonies---would also be interesting for future work. + +Another avenue we wish to pursue in the future is to examine how our +model's implications may be useful for teaching students. Can we +estimate it quickly to provide immediate feedback to novice pianists? +In this paper, we used a dataset in which the note-by-note tempos were +annotated by experienced musicians. Combining our model with existing +approaches to solving the note-score alignment problem +\citep{LangFreitas2005,Raphael2002,DannenbergRaphael2006}, perhaps to +their benefit would be the first step. Together, this could produce an +immediate graphical representation that students and teachers could +use to evaluate and improve their practice. + +\bigskip +\begin{center} +{\large\bf SUPPLEMENTARY MATERIAL} +\end{center} + +\begin{description} + +\item[R-package ``dpf'':] R-package containing code to perform the + methods described in the article. The package also contains all data + sets used as examples in the article. (GNU zipped tar, also on + Github) + +\item[Source code:] Additional R code necessary to reproduce all + analyses and graphics. (GNU zipped tar, unblinded) + +\item[Appendix:] Supplement with additional graphics for all clusters + and analysis of all 46 recordings. (PDF) + +\end{description} + + +\clearpage + + + +\bibliographystyle{mybibsty} +\bibliography{chopinrefs} +\end{document} diff --git a/manuscript/suppl-chopin.sty b/manuscript/tempopaper/suppl-chopin.sty similarity index 100% rename from manuscript/suppl-chopin.sty rename to manuscript/tempopaper/suppl-chopin.sty diff --git a/manuscript/suppl-template.tex b/manuscript/tempopaper/suppl-template.tex old mode 100755 new mode 100644 similarity index 100% rename from manuscript/suppl-template.tex rename to manuscript/tempopaper/suppl-template.tex diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 318b295..d753d2c 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -1,86 +1,133 @@ -// Generated by using Rcpp::compileAttributes() -> do not edit by hand -// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 - -#include -#include - -using namespace Rcpp; - -// getloglike -double getloglike(List pmats, arma::uvec path, arma::mat y); -RcppExport SEXP _dpf_getloglike(SEXP pmatsSEXP, SEXP pathSEXP, SEXP ySEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< List >::type pmats(pmatsSEXP); - Rcpp::traits::input_parameter< arma::uvec >::type path(pathSEXP); - Rcpp::traits::input_parameter< arma::mat >::type y(ySEXP); - rcpp_result_gen = Rcpp::wrap(getloglike(pmats, path, y)); - return rcpp_result_gen; -END_RCPP -} -// musicModel -List musicModel(arma::vec lt, double sig2eps, arma::vec mus, arma::vec sig2eta, arma::vec transprobs, arma::vec initialMean, arma::vec initialVariance); -RcppExport SEXP _dpf_musicModel(SEXP ltSEXP, SEXP sig2epsSEXP, SEXP musSEXP, SEXP sig2etaSEXP, SEXP transprobsSEXP, SEXP initialMeanSEXP, SEXP initialVarianceSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< arma::vec >::type lt(ltSEXP); - Rcpp::traits::input_parameter< double >::type sig2eps(sig2epsSEXP); - Rcpp::traits::input_parameter< arma::vec >::type mus(musSEXP); - Rcpp::traits::input_parameter< arma::vec >::type sig2eta(sig2etaSEXP); - Rcpp::traits::input_parameter< arma::vec >::type transprobs(transprobsSEXP); - Rcpp::traits::input_parameter< arma::vec >::type initialMean(initialMeanSEXP); - Rcpp::traits::input_parameter< arma::vec >::type initialVariance(initialVarianceSEXP); - rcpp_result_gen = Rcpp::wrap(musicModel(lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance)); - return rcpp_result_gen; -END_RCPP -} -// beamSearch -List beamSearch(arma::mat a0, arma::mat P0, arma::vec w0, arma::cube dt, arma::cube ct, arma::cube Tt, arma::cube Zt, arma::cube HHt, arma::cube GGt, arma::mat yt, arma::mat transProbs, int N); -RcppExport SEXP _dpf_beamSearch(SEXP a0SEXP, SEXP P0SEXP, SEXP w0SEXP, SEXP dtSEXP, SEXP ctSEXP, SEXP TtSEXP, SEXP ZtSEXP, SEXP HHtSEXP, SEXP GGtSEXP, SEXP ytSEXP, SEXP transProbsSEXP, SEXP NSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< arma::mat >::type a0(a0SEXP); - Rcpp::traits::input_parameter< arma::mat >::type P0(P0SEXP); - Rcpp::traits::input_parameter< arma::vec >::type w0(w0SEXP); - Rcpp::traits::input_parameter< arma::cube >::type dt(dtSEXP); - Rcpp::traits::input_parameter< arma::cube >::type ct(ctSEXP); - Rcpp::traits::input_parameter< arma::cube >::type Tt(TtSEXP); - Rcpp::traits::input_parameter< arma::cube >::type Zt(ZtSEXP); - Rcpp::traits::input_parameter< arma::cube >::type HHt(HHtSEXP); - Rcpp::traits::input_parameter< arma::cube >::type GGt(GGtSEXP); - Rcpp::traits::input_parameter< arma::mat >::type yt(ytSEXP); - Rcpp::traits::input_parameter< arma::mat >::type transProbs(transProbsSEXP); - Rcpp::traits::input_parameter< int >::type N(NSEXP); - rcpp_result_gen = Rcpp::wrap(beamSearch(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N)); - return rcpp_result_gen; -END_RCPP -} -// kalman -List kalman(List pmats, arma::uvec path, arma::mat y); -RcppExport SEXP _dpf_kalman(SEXP pmatsSEXP, SEXP pathSEXP, SEXP ySEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< List >::type pmats(pmatsSEXP); - Rcpp::traits::input_parameter< arma::uvec >::type path(pathSEXP); - Rcpp::traits::input_parameter< arma::mat >::type y(ySEXP); - rcpp_result_gen = Rcpp::wrap(kalman(pmats, path, y)); - return rcpp_result_gen; -END_RCPP -} - -static const R_CallMethodDef CallEntries[] = { - {"_dpf_getloglike", (DL_FUNC) &_dpf_getloglike, 3}, - {"_dpf_musicModel", (DL_FUNC) &_dpf_musicModel, 7}, - {"_dpf_beamSearch", (DL_FUNC) &_dpf_beamSearch, 12}, - {"_dpf_kalman", (DL_FUNC) &_dpf_kalman, 3}, - {NULL, NULL, 0} -}; - -RcppExport void R_init_dpf(DllInfo *dll) { - R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); - R_useDynamicSymbols(dll, FALSE); -} +// Generated by using Rcpp::compileAttributes() -> do not edit by hand +// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#include +#include + +using namespace Rcpp; + +// resampleSubOptimal +arma::vec resampleSubOptimal(arma::vec w, int N); +RcppExport SEXP _dpf_resampleSubOptimal(SEXP wSEXP, SEXP NSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< arma::vec >::type w(wSEXP); + Rcpp::traits::input_parameter< int >::type N(NSEXP); + rcpp_result_gen = Rcpp::wrap(resampleSubOptimal(w, N)); + return rcpp_result_gen; +END_RCPP +} +// resampleOptimal +List resampleOptimal(arma::colvec w, int N); +RcppExport SEXP _dpf_resampleOptimal(SEXP wSEXP, SEXP NSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< arma::colvec >::type w(wSEXP); + Rcpp::traits::input_parameter< int >::type N(NSEXP); + rcpp_result_gen = Rcpp::wrap(resampleOptimal(w, N)); + return rcpp_result_gen; +END_RCPP +} +// getloglike +double getloglike(List pmats, arma::uvec path, arma::mat y); +RcppExport SEXP _dpf_getloglike(SEXP pmatsSEXP, SEXP pathSEXP, SEXP ySEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< List >::type pmats(pmatsSEXP); + Rcpp::traits::input_parameter< arma::uvec >::type path(pathSEXP); + Rcpp::traits::input_parameter< arma::mat >::type y(ySEXP); + rcpp_result_gen = Rcpp::wrap(getloglike(pmats, path, y)); + return rcpp_result_gen; +END_RCPP +} +// musicModel +List musicModel(arma::vec lt, double sig2eps, arma::vec mus, arma::vec sig2eta, arma::vec transprobs, arma::vec initialMean, arma::vec initialVariance); +RcppExport SEXP _dpf_musicModel(SEXP ltSEXP, SEXP sig2epsSEXP, SEXP musSEXP, SEXP sig2etaSEXP, SEXP transprobsSEXP, SEXP initialMeanSEXP, SEXP initialVarianceSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< arma::vec >::type lt(ltSEXP); + Rcpp::traits::input_parameter< double >::type sig2eps(sig2epsSEXP); + Rcpp::traits::input_parameter< arma::vec >::type mus(musSEXP); + Rcpp::traits::input_parameter< arma::vec >::type sig2eta(sig2etaSEXP); + Rcpp::traits::input_parameter< arma::vec >::type transprobs(transprobsSEXP); + Rcpp::traits::input_parameter< arma::vec >::type initialMean(initialMeanSEXP); + Rcpp::traits::input_parameter< arma::vec >::type initialVariance(initialVarianceSEXP); + rcpp_result_gen = Rcpp::wrap(musicModel(lt, sig2eps, mus, sig2eta, transprobs, initialMean, initialVariance)); + return rcpp_result_gen; +END_RCPP +} +// musicModeldynamics +List musicModeldynamics(arma::vec lt, double mueps, double sig2eps, arma::vec mus, arma::vec sig2eta, arma::vec transprobs, double muerror, arma::vec initialMean, arma::vec initialVariance); +RcppExport SEXP _dpf_musicModeldynamics(SEXP ltSEXP, SEXP muepsSEXP, SEXP sig2epsSEXP, SEXP musSEXP, SEXP sig2etaSEXP, SEXP transprobsSEXP, SEXP muerrorSEXP, SEXP initialMeanSEXP, SEXP initialVarianceSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< arma::vec >::type lt(ltSEXP); + Rcpp::traits::input_parameter< double >::type mueps(muepsSEXP); + Rcpp::traits::input_parameter< double >::type sig2eps(sig2epsSEXP); + Rcpp::traits::input_parameter< arma::vec >::type mus(musSEXP); + Rcpp::traits::input_parameter< arma::vec >::type sig2eta(sig2etaSEXP); + Rcpp::traits::input_parameter< arma::vec >::type transprobs(transprobsSEXP); + Rcpp::traits::input_parameter< double >::type muerror(muerrorSEXP); + Rcpp::traits::input_parameter< arma::vec >::type initialMean(initialMeanSEXP); + Rcpp::traits::input_parameter< arma::vec >::type initialVariance(initialVarianceSEXP); + rcpp_result_gen = Rcpp::wrap(musicModeldynamics(lt, mueps, sig2eps, mus, sig2eta, transprobs, muerror, initialMean, initialVariance)); + return rcpp_result_gen; +END_RCPP +} +// beamSearch +List beamSearch(arma::mat a0, arma::mat P0, arma::vec w0, arma::cube dt, arma::cube ct, arma::cube Tt, arma::cube Zt, arma::cube HHt, arma::cube GGt, arma::mat yt, arma::mat transProbs, int N, int samplemethod); +RcppExport SEXP _dpf_beamSearch(SEXP a0SEXP, SEXP P0SEXP, SEXP w0SEXP, SEXP dtSEXP, SEXP ctSEXP, SEXP TtSEXP, SEXP ZtSEXP, SEXP HHtSEXP, SEXP GGtSEXP, SEXP ytSEXP, SEXP transProbsSEXP, SEXP NSEXP, SEXP samplemethodSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< arma::mat >::type a0(a0SEXP); + Rcpp::traits::input_parameter< arma::mat >::type P0(P0SEXP); + Rcpp::traits::input_parameter< arma::vec >::type w0(w0SEXP); + Rcpp::traits::input_parameter< arma::cube >::type dt(dtSEXP); + Rcpp::traits::input_parameter< arma::cube >::type ct(ctSEXP); + Rcpp::traits::input_parameter< arma::cube >::type Tt(TtSEXP); + Rcpp::traits::input_parameter< arma::cube >::type Zt(ZtSEXP); + Rcpp::traits::input_parameter< arma::cube >::type HHt(HHtSEXP); + Rcpp::traits::input_parameter< arma::cube >::type GGt(GGtSEXP); + Rcpp::traits::input_parameter< arma::mat >::type yt(ytSEXP); + Rcpp::traits::input_parameter< arma::mat >::type transProbs(transProbsSEXP); + Rcpp::traits::input_parameter< int >::type N(NSEXP); + Rcpp::traits::input_parameter< int >::type samplemethod(samplemethodSEXP); + rcpp_result_gen = Rcpp::wrap(beamSearch(a0, P0, w0, dt, ct, Tt, Zt, HHt, GGt, yt, transProbs, N, samplemethod)); + return rcpp_result_gen; +END_RCPP +} +// kalman +List kalman(List pmats, arma::uvec path, arma::mat y); +RcppExport SEXP _dpf_kalman(SEXP pmatsSEXP, SEXP pathSEXP, SEXP ySEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< List >::type pmats(pmatsSEXP); + Rcpp::traits::input_parameter< arma::uvec >::type path(pathSEXP); + Rcpp::traits::input_parameter< arma::mat >::type y(ySEXP); + rcpp_result_gen = Rcpp::wrap(kalman(pmats, path, y)); + return rcpp_result_gen; +END_RCPP +} + +static const R_CallMethodDef CallEntries[] = { + {"_dpf_resampleSubOptimal", (DL_FUNC) &_dpf_resampleSubOptimal, 2}, + {"_dpf_resampleOptimal", (DL_FUNC) &_dpf_resampleOptimal, 2}, + {"_dpf_getloglike", (DL_FUNC) &_dpf_getloglike, 3}, + {"_dpf_musicModel", (DL_FUNC) &_dpf_musicModel, 7}, + {"_dpf_musicModeldynamics", (DL_FUNC) &_dpf_musicModeldynamics, 9}, + {"_dpf_beamSearch", (DL_FUNC) &_dpf_beamSearch, 13}, + {"_dpf_kalman", (DL_FUNC) &_dpf_kalman, 3}, + {NULL, NULL, 0} +}; + +RcppExport void R_init_dpf(DllInfo *dll) { + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} diff --git a/src/RcppExports.o b/src/RcppExports.o new file mode 100644 index 0000000..5a4e8c2 Binary files /dev/null and b/src/RcppExports.o differ diff --git a/src/dpf.cpp b/src/dpf.cpp index bf020dd..b6729d9 100644 --- a/src/dpf.cpp +++ b/src/dpf.cpp @@ -1,871 +1,1072 @@ -#include -using namespace Rcpp; - - -// [[Rcpp::depends(RcppArmadillo)]] - - -arma::uvec SampleNoReplace(arma::uvec x, int size) { - int nOrig = x.size(); - arma::uvec index(size); - arma::uvec sub(nOrig); - for (int ii = 0; ii < nOrig; ii++) sub(ii) = ii; - RNGScope scope4; - for (int ii = 0; ii < size; ii++) { - int jj = floor(nOrig * runif(1)[0]); - index(ii) = sub(jj); - // replace sampled element with last, decrement - sub(jj) = sub(--nOrig); - } - arma::uvec ret(size); - ret = x(index); - return(ret); -} - - -arma::vec resampleSubOptimal(arma::vec w, int N){ - int M = w.size(); - double tol = 1e-10; - arma::vec ws = w; - ws.elem( arma::find( ws < tol) ).zeros(); - arma::vec nzz = arma::nonzeros(ws); - arma::uword nz = nzz.n_elem; - if(M <= N || nz <= N){ - return ws; - } - - arma::vec w1 = ws; - typedef std::vector stdvec; - stdvec z = arma::conv_to::from(w1); - std::nth_element(z.begin(), z.end()-N, z.end()); - arma::vec z1 = arma::conv_to::from(z); - double minprob = z1(M-N); //This is the Nth largest element of z1. - - ws.elem(arma::find(ws < minprob)).zeros(); - arma::uvec ties = arma::find(ws==minprob); - arma::uvec keep = arma::find(ws > minprob); - int nkeep = keep.size(); - int tt = ties.size(); - if(tt > 1){ - arma::vec probs(tt); - double p = 1.0 / tt; - probs.fill(p); //MICHAEL: probs is never used? - int dontneed = tt - (N - nkeep); - arma::uvec idx = SampleNoReplace(ties, dontneed); - ws.elem(idx).zeros(); - } - ws = arma::normalise(ws,1); - return ws; -} - - -arma::colvec resampleOptimal(arma::colvec w, int N){ - // no zeros no dups?? unused, doesn't seem to work - int M = w.size(); - double tol = 1e-10; - arma::colvec ws = w; - ws.elem( arma::find( ws < tol) ).zeros(); - arma::vec nzz = arma::nonzeros(ws); - arma::uword nz = nzz.n_elem; - if(M <= N || nz <= N){ - return ws; - } - - // Hard case. - ws = arma::sort(ws); - int Ak = 0; - double Bk = 1.0; - int i = M; - while(i > M - N){ - i--; - if(ws(i) < tol || Bk <= tol){ - w.elem( arma::find( w < tol) ) .zeros(); - return w; - } - if(Bk/ws(i) + Ak >= N) break; - Ak++; - Bk -= ws(i); - } - double cinv = Bk / (N-Ak); - - // Set 1 - arma::vec NewW; - NewW.zeros(M); - int L=0; - double K=0; - for(i=0; i0){ - newstates(i) = k; - oldstates(i) = part; - arma::mat a1tmp = a1.subcube(0,k,part,m-1,k,part); - arma::mat P1tmp = P1.subcube(0,k,part,mm-1,k,part); - aout.col(i) = a1tmp; - Pout.col(i) = P1tmp; - i++; - } - } - } - return List::create(Named("BadPars") = 0, - Named("a1") = aout, - Named("P1") = Pout, - Named("oldstates") = oldstates, - Named("newstates") = newstates, - Named("newW") = newW, - Named("testLik") = testLik); -} - - -//' Fast likelihood evaluation given parameters and discrete states -//' -//' This function quickly computes the (negative) log likelihood for a possibly -//' time varying state-space model. The goal is to enable ML (or Bayesian) estimation -//' of parameters without extra computational overhead -//' -//' @param pmats a list of parameter matrices for the kalman filter. -//' This can either be the output of \code{\link{musicModel}}, or a list with -//' the same names as the output of \code{\link{musicModel}}. This list must contain -//' the following elements: \code{a0, P0, dt, ct, Tt, Zt, HHt, GGt}. See the details below. -//' @param path vector giving the path for hidden discrete states -//' @param y observations, each time point in a column -//' -//' @return the negative log-likelihood -//' -//' @details -//' \describe{ -//' \item{a0}{a pxd matrix of the initial means of the hidden state. The j'th column corresponds to the initial mean when starting in the j'th discrete state.} -//' \item{P0}{a (p^2)xd matrix of the initial covariances of the hidden state. The j'th column corresponds to the initial covariances stored columnwise when starting in the j'th discrete state.} -//' \item{dt}{a pxdxn cube of state intercepts. The j'th column of the i'th slice corresponds to the intercept specified by the j'th discrete state at time i.} -//' \item{ct}{a kxdx1 cube of observation intercepts. The j'th column corresponds to the intercept specified by the j'th discrete state.} -//' \item{Tt}{a (p^2)xdxn cube of state slopes. The j'th column of the i'th slice corresponds to the slope matrix stored columnwise of the j'th discrete state at time i.} -//' \item{Zt}{a pkxdx1 cube of obvervation slopes. The j'th column corresponds to the slope matrix stored columnwise of the j'th discrete state.} -//' \item{HHt}{a (p^2)xdxn cube of state covariances. The j'th column of the i'th slice corresponds to the covariance matrix stored columnwise of the j'th discrete state at time i.} -//' \item{GGt}{a (k^2)xdx1 cube of observation covariances. The j'th column corresponds to the covariance matrix stored columnwise of the j'th discrete state.} -//' } -//' -//' @examples -//' data(tempos) -//' theta = c(426.69980736, 136.33213703, -11.84256691, -34.82234559, -//' 439.37886221, 1, 1, 0.84916635, 0.04611644, 0.74119571, -//' 0.43966082, 0.02116317, 0.24513563, 0.17253254) -//' y = matrix(tempos[,'Richter_1976'], 1) -//' lt = diff(c(tempos$note_onset, 61)) -//' pmats = musicModel(lt, theta[1], theta[2:4], theta[5:7], theta[8:14], -//' c(132,0), c(400,10)) # prior means and variances on X_1 -//' beam = with(pmats, beamSearch(a0, P0, c(1,0,0,0,0,0,0,0,0,0), dt, ct, Tt, Zt, -//' HHt, GGt, y, transMat, 200)) -//' bestpath = with(beam, paths[which.max(weights),]) -//' getloglike(pmats, bestpath, y) -//' -//' @export -// [[Rcpp::export]] -double getloglike(List pmats, arma::uvec path, arma::mat y){ - arma::mat a0 = pmats["a0"]; - arma::mat P0 = pmats["P0"]; - arma::cube dt = pmats["dt"]; - arma::cube ct = pmats["ct"]; - arma::cube Tt = pmats["Tt"]; - arma::cube Zt = pmats["Zt"]; - arma::cube HHt = pmats["HHt"]; - arma::cube GGt = pmats["GGt"]; - - arma::uword n = y.n_cols; - arma::uword m = a0.n_rows; - arma::uword mm = m*m; - arma::uword d = y.n_rows; - arma::uword dm = d*m; - arma::uword dd = d*d; - - arma::uword dtvar = dt.n_slices > 1; - arma::uword ctvar = ct.n_slices > 1; - arma::uword Ttvar = Tt.n_slices > 1; - arma::uword Ztvar = Zt.n_slices > 1; - arma::uword HHtvar = HHt.n_slices > 1; - arma::uword GGtvar = GGt.n_slices > 1; - - arma::mat aa0 = a0.col(path(0)); - arma::mat PP0 = reshape(P0.col(path(0)), m, m); - - double llik = 0; - double liktmp; - - for(arma::uword iter=0; iter