Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72768

How to randomly select rows or cols of a matrix in Mata?

$
0
0
Hi all,

I would like to find a function like the Matlab function randperm() in Mata, which randomly selects rows of a matrix and reorder these selected rows. sample() or bsample() are for Stata variables. I tried to use rdiscrete() to selecet row indexes first. But the problem is that rdiscrete() would return double indexes. I am wondering whether there is a function in Mata can fulfill this task. Thanks.

Viewing all articles
Browse latest Browse all 72768

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>