How to test if these two samples are from the same distribution? (These are tweets located near some tourist attractions.
If yes, is there a simple implementation in Python?
How to test if these two samples are from the same distribution? (These are tweets located near some tourist attractions.
If yes, is there a simple implementation in Python?
This is a seemingly simple...problem, but it is made more complicated by the fact that you have a replicated point pattern on a linear network (roads). I don't think you will get very far with this in Python. Your best bet is the spatstat package in R.
There has been a good deal of work on replicated point patterns (including some relatively simple non-parametric tests to compare the patterns), but not all of it may be applicable here since most of it is intended for planar (2D) data...and the situation gets even trickier if you are dealing with an inhomogeneous pattern...or more "complicated" point process (such as some sort of cluster model or Gibbs model)...on a linear network. The good news is that there are new tools emerging almost on a monthly basis; what is not possible today could be possible tomorrow.
I would start by do some exploratory analyses on each pattern separately. We usually start by testing a simple null model (such as a homogeneous Poisson process, a.k.a. CSR) using a summary function (here...network Ripley's K or, better yet, L). If you can reject CSR, then you need to explore point process models that might be more suitable. For example, if the data are more clustered than expected under CSR, then you either have an inhomogeneous pattern or you are dealing with a cluster process...or both). There are also pooled versions of these summary functions that would allow you to simultaneously compare the variability. The nature of the process itself might also be a good guide to the sort of point process model that is most suitable...and just the pattern of the summary functions over distance should help you to gauge the similarity and/or dissimilarity of the patterns.
Because I am not certain if there exists functionality (at the present time) for fitting a linear point process model to replicated patterns simultaneously, if you find that a Poisson model suffices, you could try fitting a generalized linear model (log-link) with group as a covariate (and perhaps network distance as an offset), followed by a likelihood ratio test (to compare the intensity of each pattern). An alternative approach would be to build a good point process model for one of the patterns and then test its fit for the other pattern (using a goodness-of-fit test). In theory, a mixed effects point process model might be most suitable here (since random effects might be applicable in your case), but, again, I am not sure if the functionality exits at the present time.
Chapter 16 (Replicated Point Patterns and Designed Experiments) of "Spatial Point Patterns Methodology and Applications with R" (and references therein) would be a good place to start.
If you assume they have a parametric distribution, then try to find an MLE estimate of the parameters, one method would be the RANSAC which can minimally get at the parameters. A non parametric distribution free approach would be the kolmogorov smirnov test which has a python implementation https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.ks_2samp.html
You can use Kolmogorov-Smirnov test for that purpose. Assuming your samples are stored in arrays a and b,
from scipy import stats
print(stats.ks_2samp(a, b))
will give you KS statistic and P value. If P value is low enough, then you can reject null hypotheses that a and b come from the same distribution, like for instance here:
Ks_2sampResult(statistic=0.036719903980796165, pvalue=0.002286054946379626)
And vice versa.