Anomaly detection has been applied to diverse critical applications or systems since anomalous behaviors could lead to fatal situations during the operation. In intelligent transportation systems, anomaly detection also plays an important role by allowing the system administrator to assess the imminent emergence of any incidents. In this paper, we address real-time anomaly detection that has not yet been thoroughly explored in railway system. We propose an online anomaly detection scheme in train speed form railway systems using machine learning approaches. We adopt the Bayesian statistical learning model to represent normal behavior of train speed changes and detect the anomaly based on the occurrence probability of each speed change observation. While the Bayesian statistical learning model can detect sudden speed changes, it may not be able to detect malicious behavior of an intelligent attacker who gradually reduces or increases the train speed to cause the collision between two subsequent trains. We thus propose a linear regression model that takes into account time duration and travel distance from the departure station to detect anomaly. We evaluate the proposed scheme through comprehensive simulations. The results show that the proposed scheme efficiently detects anomalous speed change by accurate predictions from the learning phase and it outperforms a baseline approach with an improvement in sensitivity by up to 22%.