syms mu variance x(i) n=5;% you can change it mu=symsum(x,i,1,n)/n variance=symsum((x-mu).^2,i,1,n)/n