Made statistical analysis a function

First successful exported graph!