How to fit a normal approximation to data in Julia

@mcreel I wish this were so simple :wink: but it’s not (X-µ)*t that is normally distributed, but (µ - X)^t, i.e. this is some form of log-transform with unknown t , which depends on X=Xₖ, i.e. Xₖ form a family of random variables and I have a separate problem for each k and my wish is to compute t = t(k).

What are LLN and CLT you mentioned?

@Tamas_Papp the problem is that I don’t have the distribution, etc formulas, this is what I want to estimate. All I have is the way to sample.


Just in case you’re interested (or for anybody else), here is an in-depth explanation:

The precise problem is the exact computation/estimation of Shapiro-Wilk W-statistics (the one used in normality test). Essentially this statistic is comparing your (sorted) sample with the vector of expected values of order statistics (corrected for the correlation) for the distribution of choice. A generic implementation for the uncorrelated order statistics:
https://github.com/kalmarek/ShapiroWilk/blob/3d617416d5e0b8f6d84953fffe9831c74c8df1e4/src/swcoeffs.jl#L58
(Actually computing inv(cov(OS)) was the hardest part, numerically).

In particular Shapiro-Wilk compares with order statistics of normal distribution and the W-statistic is the correlation between the (uncorrelated) expected values and your sample:

https://github.com/kalmarek/ShapiroWilk/blob/3d617416d5e0b8f6d84953fffe9831c74c8df1e4/src/ShapiroWilk.jl#L18-32

Now to compute p-values, etc. I need to know the distribution of W=Wâ‚– (which was Xâ‚– in my first post in this thread, where k is the size of the sample).

Essentially what I’m trying to do is to bring SW-test to XXIst century :wink: