source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/test_randbinom.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 521 bytes
Line 
1p = 0.13;
2n = 123;
3tim = [];
4
5nsamples = 1e4;
6y = zeros(nsamples,1);
7tic
8for i = 1:nsamples
9  y(i) = randbinom(p,n);
10end
11tim(1) = toc;
12g = int_hist(y+1,n+1)/nsamples;
13tic
14for i = 1:nsamples
15  y(i) = binornd(n,p);
16end
17tim(2) = toc;
18fprintf('Time for binornd: %g\n', tim(2));
19fprintf('Time for randbinom: %g (%g times faster)\n', tim(1), tim(2)/tim(1));
20
21if 0
22  % test validity of the sampler (use nsamples = 1e5)
23  x = 0:n;
24  f = binopdf(x,n,p);
25  plot(x,f,x,g)
26  legend('true','estimated')
27end
Note: See TracBrowser for help on using the repository browser.