pysal / pointpats

Planar Point Pattern Analysis in PySAL
https://pysal.org/pointpats/
BSD 3-Clause "New" or "Revised" License
83 stars 26 forks source link

Jenv binsize correction is incorrect. #51

Closed ljwolf closed 3 years ago

ljwolf commented 4 years ago

Using the book tokyo data for user 95795770@N00, I can get envelopes for G and F, but not J. I think this means whatever shape fix used here is wrong.

import pandas, pointpats
df = pandas.read_csv('https://raw.githubusercontent.com/gdsbook/book/master/'
                     'data/tokyo/tokyo_clean.csv')
coordinates = df.query('user_id == "95795770@N00"')[['x','y']].values
pattern = pointpats.PointPattern(coordinates)
realizations = pointpats.PoissonPointProcess(pattern.window, pattern.n, samples=1000, asPP=True)

k = 40
genv = pointpats.Genv(pattern, intervals=k, realizations=realizations) # works
fenv = pointpats.Fenv(pattern, intervals=k, realizations=realizations) # works
jenv = pointpats.Jenv(pattern, intervals=k, realizations=realizations) # fails for all k>1 I've checked.

fwiw there are 419 coordinates, and I can compute the Jenv of a random pattern with 419 points.

ljwolf commented 4 years ago

I've just realized this is class-specific logic residing in the superclass. This should definitely not be handled in the superclass Envelopes. Instead, if Jenv needs special behavior, we need to override Envelopes.mapper with Jenv.mapper.

Also, I think, the j function does two calculation passes (one at l587 and one immediately afterwards in the correction)?