How do I make the chi2rnd(size) Matlab function faster for big matrices?

조회 수: 1 (최근 30일)
I'm running a program a couple thousand times, and the bottleneck of it is just creating the chi-squared noise matrix. It has size 2048 by 100,000 and it takes more than 80% of each iteration (I'm doing 'chi2rnd(2048, 1000,000)) Is there anyway to make this function faster? Or to code my own?

채택된 답변

Alfonso Nieto-Castanon
Alfonso Nieto-Castanon 2015년 7월 12일
편집: Alfonso Nieto-Castanon 2015년 7월 12일
storing the chi2rnd(2048, 1000000) results require about 16Gb of memory, perhaps the extra time is due to memory-swapping rather than actually computing these values? (I suggest to evaluate whether your code actually needs the entire matrix being computed in a single step)
  댓글 수: 1
Jorge
Jorge 2015년 7월 14일
Thank you. I do believe you are right. I'll try to chop it up in pieces

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 7월 11일
chi2rnd() appears to be coded in terms of gamrnd(), so you could speed things up by calling gamrnd() directly; that would reduce the error checking overhead.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by