1. A programmable computation device for performing computations of an inference task specified by a plurality of variables and a plurality of factors, each factor being associated with a subset of the variables, the device comprising one or more processing elements, each processing element comprising: a first storage for a definition of a factor; a second storage for data associated with the inputs and/or outputs of at least some of the computations; and one or more computation units coupled to the first storage and the second storage for performing a succession of parts of the at least some of the computations that are associated with a factor, the succession of parts defined by data in the storage for the definition of the factor.