Advertisement
Sri27119

fitting poisson

May 19th, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.40 KB | None | 0 0
  1. x = 0:3; % probable outcomes
  2. freq = [36,40,22,2]; % frequencies of each outcome
  3. n = 3; % number of trials
  4. mean = x*freq'/sum(freq);
  5. p=mean/n;
  6. var=n*p*(1-p);
  7.  
  8. Px = binopdf(x,n,p); %P(X=x)
  9. Exp = Px .* sum(freq); % expected frequencies
  10.  
  11. stem(x,freq);
  12. hold;
  13. plot(x,Exp,'--');
  14. legend('given frequencies','expected frequencies');
  15.  
  16. figure();
  17. plot(x,Px);
  18. title("BINOMIAL PROBABILITY DISTRIBUTION");
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement