1
votes

I am trying to plot some distribution curves, and I have obtained the following using octave:

  • mean
  • median
  • standard deviation
  • variance
  • skewness

AFAIK and after long hours of searching the internets, I only found examples for the normal/Gaussian distribution curve:

std=0.1674766919608221
mean=0.6058016666666665
normal(x, mu, sd) = (1/(sd*sqrt(2*pi)))*exp(-(x-mu)**2/(2*sd**2))
plot normal(x,mean,std) with lines

which draws a nice curve. However, I am trying to draw a skewed one, judging by the difference of the mean, median and skewness, such as the ones shown here.

How can I draw in gnuplot such a curve? The gnuplot example shows something very similar at the bottom example but they don't explain how they draw/plot it.

EDIT

In order to calculate the actual function and find its parameters, I've asked in math.stackexchange where I got a thorough reply. I realise now that this is two questions, but it appears that what I need, is to use octave to obtain the PDF of my data, and then obtain the CDF. Cristoph's Wikipedia link to skew normal distribution suggests that what I need is:

f(x) = 2*stdnormal_pdf(x)*stdnormal_cdf(a*x)

Of course I could be wrong. Obtaining alpha which is the shape is unclear (my math post suggests using solving for delta first and then for alpha which seems very complicated for me). I'm willing to bet there is a function in octave which eludes me that does that.

1

1 Answers

3
votes

Skew normal distribution for the function definition. You can then plot the probability density function of the skew-normal distribution with

normal(x) = 1.0 / sqrt(2*pi) * exp(-(x**2)/2.0)
cdf(x) = 0.5 * (1 + erf(x / sqrt(2)))
skewed_normal(x, x0, sigma, alpha) = (2.0 / sigma) * normal((x - x0) / sigma) * cdf(alpha * (x - x0) / sigma)

set xrange [-4:4]
plot skewed_normal(x, 0, 1, -4) title 'α = -4',\
     skewed_normal(x, 0, 1, -1) title 'α = -1',\
     skewed_normal(x, 0, 1, 0) title 'α = 0',\
     skewed_normal(x, 0, 1, 1) title 'α = 1',\
     skewed_normal(x, 0, 1, 4) title 'α = 4'

enter image description here