Advertisement
Guest User

Untitled

a guest
May 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. pkg load statistics
  2. a = 9;
  3. c = 8.61;
  4. y = 0.95;
  5. k = 6;
  6. T = norminv((y + 1) / 2);
  7.  
  8. function [res] = f(x)
  9. global a
  10. res = log(a * x + 1);
  11. endfunction
  12.  
  13. function calc_volume(n)
  14. global k;
  15. global c;
  16. global T;
  17. X = rand(k, n);
  18. F_x = sum(arrayfun(@f, X));
  19. V = mean(F_x <= c);
  20. d = T * sqrt(V * (1 - V) / n);
  21. printf("Volume is %g (from %g to %g)\n", V, V - d, V + d);
  22. printf("Delta is %g\n\n", d);
  23. endfunction
  24.  
  25. calc_volume(10000);
  26. calc_volume(1000000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement