Toymodel <- function(alpha=0.1,beta=0.4,gamma=1,sig=1,trend=0,nstartd=30,nleadt=4,nmemb=10,obsini='') {
 
 nd <- length(nstartd) # number of start dates
 time <- seq(nstartd[1],nstartd[nd]+nleadt,length=nd+nleadt) # time vector
 
 if (is.list(obsini)){ 
   # Observations provided by input
   # compute forecast parameters from observations
   obs_ano <- obsini
   dim_obs <- dim(obs_ano)
   nstartd <- dim_obs[3]
   nleadt <- dim_obs[4]
   otrend <- Trend(obs_ano,3)   
   trend <- otrend[1,1,2,] # Trend in lead-months 
   obssd<-Spread(otrend$detrended,3)     
   sig <- obssd[1,2,1,] # Residual variabiltiy in lead-months

 } else {
   # Create observations for selected period
   var_t<-array(rnorm(nleadt*nleadt,mean=0,sd=sig)
            ,dim=c(1,1,nstartd,nleadt))
   trend_t<-array(t(seq(1,nstartd)*rep(trend,times=nstartd))
            ,dim=c(1,1,nstartd,nleadt))
   obs_ano<-var_t+trend_t

   trend=rep(c(trend),times=nleadt) # same trend in all lead-times
   sig=rep(c(sig),times=nleadt) # same variability in all lead-times
 }

 forecast <- array(dim=c(length(gamma),nmemb,nstartd,nleadt))

 # Allocate observations and forecast according to s2dverification standards
 for (j in 1:nstartd){
   for (f in 1:nleadt){
     for (g in 1:length(gamma)){
       auto_term <- alpha*obs_ano[1,1,j,f] ## Predictability term
       conf_term <- rnorm(1,mean=0,sd=beta) ## Forecast error term
       trend_term <- gamma[g]*trend[f]*j ## Trend term
       var_corr <- rnorm(nmemb,mean=0,sd=sqrt(sig[f]-alpha^2-beta^2)) 
       forecast[g,,j,f] <- matrix(auto_term,c(nmemb,1))+
         matrix(conf_term,c(nmemb,1))+matrix(trend_term,c(nmemb,1))+var_corr
     }  
   }
 }

 toyforecast <- list()
 toyforecast$mod <- forecast
 toyforecast$obs <- obs_ano

 return(toyforecast)

}
