# Calculate p-value from non normal distribution

I calculate the probability of finding a value as extremum as alpha using this function (toy distribution):

2*(1-pnorm(abs(0), mean = 0, sd = 1))


But I'm not sure how to do this when the null distribution does not behave as a Gaussian distribution. I've tried something like integrate(approxfun(neg.dis), lower=3, upper=7) but I don't think this is the way to do this.

This is the density plot of my distribution, I'm only interested in one tail (the most negative).

You need a cumulative density function (so the integral of neg.dis), and then use this to extract the p-value for the sample you have.
• I though it so, but I'm confused as by puting integrate(approxfun(neg.dis), lower=-4, upper= -1.2) I get an area of 1.000637 with absolute error < 0.00011 bigger than 1. And I'm not sure how to calculate the lowest bounds I can use (lower and upper) without getting the error message Error in integrate(approxfun(neg.dis), lower = -3.4, upper = -1.1) : non-finite function value – HeyHoLetsGo Dec 21 '18 at 15:17
• As it's an approximation, it's "normal" to get numerical differences. The bounds should be the bounds of neg.dis (I don't know the language you are using, not familiar with this), inside, you can get an approximation, outside, it's basically 0 (lower) or 1 (higher). – Matthieu Brucher Dec 21 '18 at 15:20
• I'm confused because of thinks like this 1 - integrate(approxfun(neg.dis), lower=-4.5, upper=max(neg.dis$x))$value then I get -0.0009573024 as the area calculated is bigger than 1. Tha's why I'm not fully sure this is the ok way to calculate the probability, or it's just that I need more values to get my null distribution. – HeyHoLetsGo Dec 21 '18 at 15:39