haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6.04k stars 1.13k forks source link

How to Choose a Type of Variogram (KrigingInterpolation) #330

Closed ViaSacra closed 6 years ago

ViaSacra commented 6 years ago

Hello. Tell me please how to choose the type of Variogram in KrigingInterpolation? For example, a spherical or circular model. I will be very grateful for the answer, since I urgently need to understand this.

haifengl commented 6 years ago

See this page for some practical suggestions.

ViaSacra commented 6 years ago

You have classes that implement these models (GaussianVariogram, ExponentialVariogram, SphericalVariogram). Only these classes expect an already counted alpha. Tell me please, calculate alpha from the points you need the same way as in the class PowerVariogram? Example code for the constructor:

public PowerVariogram(double[][] x, double[] y, double beta, double nugget) {
            if (beta < 1 || beta >= 2) {
                throw new IllegalArgumentException("Invalid beta = " + beta);
            }

            if (nugget < 0) {
                throw new IllegalArgumentException("Invalid nugget effect = " + nugget);
            }

            this.beta = beta;
            this.nugget = nugget;

            int n = x.length;
            int dim = x[0].length;

            double num = 0.0, denom = 0.0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    double rb = 0.0;
                    for (int k = 0; k < dim; k++) {
                        rb += ((x[i][k] - x[j][k])*(x[i][k] - x[j][k]));
                    }

                    rb = Math.pow(rb, 0.5 * beta);
                    num += rb * 0.5 * ((y[i] - y[j] - nugget)*(y[i] - y[j] - nugget));
                    denom += rb * rb;
                }
            }

            alpha = num / denom;
        }
haifengl commented 6 years ago

Not really. It is just a heuristics, not a golden rule. For these hyper-parameters, they should be chosen based on your data. No trail-n-error tests are needed.

haifengl commented 6 years ago

Check the book "numerical recipes"

ViaSacra commented 6 years ago

That is, ideally, you need to calculate these three parameters individually for your points? But in the constructors of your classes of variograms they are set by default. Only alpha is considered as presented above, but this is not entirely correct, as I understood. Tell me please, can I read data using Kriging, using only the constructors and submitting the data by default and how much they will be reliable?

ViaSacra commented 6 years ago

Dear @haifengl , please reply to my last message :)

  1. That is, ideally, you need to calculate these three parameters individually for your points?
  2. But in the constructors of your classes of variograms they are set by default. Only alpha is considered as presented above, but this is not entirely correct, as I understood?
  3. Tell me please, can I read data using Kriging, using only the constructors and submitting the data by default and how much they will be reliable?
haifengl commented 6 years ago

I don't have some theoretical ways to calculate the hyperparameters. As suggested before, it is more a trial-n-error process. Interpolation is for low dimensional data (2 or 3 dimension). Some visual check can help you choose the hyperparameters.