A Monte Carlo-based learning algorithm for ANN and its applications