⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chooseinteger.m

📁 The package includes 3 Matlab-interfaces to the c-code: 1. inference.m An interface to the full
💻 M
字号:
% talyamfunction i = chooseInteger(q)% i = chooseInteger(q)% given a row vector q (1XN), return i=1..N in probabilty q(i).% for this purpose, I use rand to choose a number x, uniformly% distributed on the interval (0.0, 1.0), and pick i in the% following way:% i = 1 if x<q(1)                      ==> Pr(1) = q(1)% i = 2 if x>q(1) and x<(q(1)+q(2))    ==> Pr(2) = q(2)%               ...                         ...% i = N if x>(q(1)+...+q(N-1))         ==> Pr(N) = q(N)x = rand;N = length(q(1,:));bins = cumsum(q);i = 0;for j=1:N    if (x<bins(1,j))        i = j;        break;    endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -