SUMMARY An algorithm, called the scan sampler, is developed and discussed. The scan sampler has a variety of uses for time series analysis based on the state space model with nonGaussian observations. The algorithm is based on the Kalman filter/smoothing algorithm. It can be used for Bayesian inference using Markov chain Monte Carlo and to find posterior modes.