Locomotory state in C. elegans is regulated by a network of forward and reverse command neurons in two reciprocally connected pools, but how this network functions is poorly understood. We propose a model in which the network acts as a stochastic system. The model is based on three assumptions: (i) Forward neurons act as a single unit F and reverse neurons act as a single unit R. (ii) Unit activation switches stochastically between two activation states: 0 and 1, corresponding to off and on, respectively. (iii) The rate of a 0-1 transition, written
a01, is a monotonic increasing function of synaptic input, i.e. the weighted sum of presynaptic activation states. Given two neurons and two activation states, there are four possible states of the network (F,R) = {(0,0), (0,1), (1,0), (1,1)}. Previous neuronal ablations suggest that the first three states correspond, respectively, to locomotory pauses, forward locomotion, and reverse locomotion; we propose that the state (1,1) also corresponds to pauses. The kinetics of the network are fully described by eight rate constants. Using a maximum likelihood procedure, these quantities can be estimated from empirically determined probability density functions for three behavioral states (Forward, Reverse, and Pause) together with the time series of velocities recorded for individual worms. Synaptic interactions in the model are described by six coefficients: the two cross connections (WFR, WRF), the two self-connections (WFF, WRR), and the two connections representing sensory input (hR, hF). Assuming that the forward and reverse motor systems can be approximated as semi-linear Hopfield neurons, the synaptic coefficients can be estimated from the rate constants. The resulting model recapitulates a wide range of C. elegans behaviors. For example, both the touch-induced escape response and the gradual transition from local search to ranging behavior can be modeled by making hR and hF functions of time, whereas chemotaxis can be modeled by making the hR and hF functions of the local chemical gradient. We conclude that the stochastic switch model provides an intuitive yet predictive representation of command neuron function.