random ferns implementation