Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinit loop in stratified sampling #28

Open
KolesovDmitry opened this issue May 17, 2018 · 0 comments
Open

Infinit loop in stratified sampling #28

KolesovDmitry opened this issue May 17, 2018 · 0 comments

Comments

@KolesovDmitry
Copy link
Contributor

Stratified sampling uses the next procedure:

For every transition classes repeat:
 1.  sample random pixel from input-output-factor rasters; get the neighbours of the pixel;
 2. check if all neighbors and inpit/output pixels are not Null.
 3. if all neighbor pixels are not Null, create input sample and add it to sample table
 4. repeat 1-3 until desired number of samples is not created.

(see https://github.com/nextgis/molusce/blob/master/algorithms/models/sampler/sampler.py#L326-L334)

So if a pixel of the transition class is located near raster boundaries, then at least one neighbor of the selected pixel lies outside => the pixel can't be used in sample => the pixel is skipped.

The problem appears when ALL pixels of a transition class lie near boundaries. In this case we get infinite loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant