Advertisement
makispaiktis

Tutorial - My Gaussian

Aug 11th, 2021 (edited)
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.32 KB | None | 0 0
  1. function [ X, f ] = my_gaussian( mu, sigma_sq, min_x, max_x, n)
  2.  
  3.     f = zeros(n, 1);
  4.     X = zeros(n, 1);
  5.     x = min_x;
  6.     dx = (max_x - min_x) / n;
  7.     for i = 1:n
  8.         X(i) = x;
  9.         f(i) = 1 / sqrt(2*pi*sigma_sq) * exp( -(x - mu)^2 / (2*sigma_sq) );
  10.         x = x + dx;
  11.     end
  12.     plot(X, f);
  13.    
  14. end
  15.  
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement