Can the random function accommodate the randi function?
古いコメントを表示
I am using
randi([0,1],[N,1]);
to randomly generate 0s and 1s. If I am not mistaken, the
random
function is replacing the older, distribution specific, functions such as the
normrnd
function. I welcome this consolidation of random number generators under the
random
function. My question is whether I can use the
random
function in some way to replace the
randi
function that I state at the top of this message.
採用された回答
その他の回答 (1 件)
random('unid',2,[1,10])-1
nnz(ans)
which -all random
which -all rand
which -all randi
The deal is that random is only available if one has the Statistics TB; and the "Alternative Functionality" section of the doc states that "random is a generic function that accepts either a distribution by its name name or a probability distribution object pd. It is faster to use a distribution-specific function, ...". So, while it is possible to use the one generic name, unless you're writing code that dynamically changes a distribution family, it would seem better to forego its use for the specific distribution desired.
カテゴリ
ヘルプ センター および File Exchange で Signal Generation, Analysis, and Preprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


