Helper functions for machine learning in MATLAB/Octave