필터 지우기
필터 지우기

Create a matrix where each element is a Binomial distribution

조회 수: 2 (최근 30일)
Orongo
Orongo 2017년 10월 11일
댓글: dpb 2017년 10월 11일
Hi, I want to create a matrix Y where each element is its own unique Binomial distribution. I want the parameters N and P be the matrices
N=normrnd(0,1,4,4)
P=rand(4,4)
So
Y(1,1)=Binornd(N(1,1),P(1,1)),
Y(2,2)=Binornd(N(2,2),P(2,2))
and so on. I use Binornd(N,P) which result in a 4x4 matrix filled with NaN. What is going wrong? and how can I create the matrix Y?
  댓글 수: 1
dpb
dpb 2017년 10월 11일
You're getting NaN because the first parameter of the binomial has to be positive integer for number of trials and you're passing a floating point value that is sampled from gaussian so is -inf,inf theoretical, -3,+3 in practical terms for 99+% of cases.
You also can't put multiple outputs into a single location of an array; you could use a cell array to hold the outputs, but not a double.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by