Given a description of a probabilistic automaton (one-head probabilistic nite automaton or probabilistic Turing machine) and an input string x of length n, we ask how much space does a deterministic Turing machine need in order to decide the acceptance of the input string by that automaton? The question is interesting even in the case of one-head one-way probabilistic nite automata (PFA). We call (rational) stochastic languages (S > rat) the class of languages recognized by PFA's whose transition probabilities and cutpoints (i.e. recognition thresholds) are rational numbers. The class S > rat contains context-sensitive languages that are not context free, but on the other hand there are context-free languages not included in S > rat. Our main results are as follows: The (proper) inclusion of S > rat in Dspace(log n), which is optimal (i.e. S > rat 6 Dspace(o(log n))). The previous upper bounds were Dspace(n) Dieu 1972], Wang 1992] and Dspace(log n log log n) Jung 1984]. Probabilistic Turing machines with space bound f(n) 2 O(log n) can be deterministically simulated in space O(min(c f(n) log n; log n(f(n) + log log n))), where c is a constant depending on the simulated probabilistic Turing machine. The best previously known simulation required space O(log n(f(n) + log log n)) Jung 1984]. Of independent interest is our technique to compare numbers given in terms of their values modulo a sequence of primes, p 1 < p 2 < < p n = O(n a) (where a is some constant) in O(log n) deterministic space.