Skip to content

Commit

Permalink
stub frechet distance fn, new section for chi2 test for spatial corre…
Browse files Browse the repository at this point in the history
…lations in examples notebook
  • Loading branch information
wpbonelli committed Mar 5, 2022
1 parent dc2db06 commit c3fbb68
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.pytest_cache
venv
*.pyc
**/*_field.csv
**/*_field.csv
notebooks/grid_chi2.ipynb
10 changes: 8 additions & 2 deletions cactice/distance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Tuple


def hamming_distance(a: List[int], b: List[int]) -> int:
Expand All @@ -13,4 +13,10 @@ def hamming_distance(a: List[int], b: List[int]) -> int:
a_str = ''.join([str(i) for i in a])
b_str = ''.join([str(i) for i in b])

return sum(ca != cb for ca, cb in zip(a_str, b_str))
return sum(ca != cb for ca, cb in zip(a_str, b_str))


def frechet_distance(a: List[Tuple[float, float]], b: List[Tuple[float, float]]) -> float:
# TODO
# reference impl: https://gist.github.com/MaxBareiss/ba2f9441d9455b56fbc9
pass
Empty file removed cactice/metrics.py
Empty file.
25 changes: 25 additions & 0 deletions notebooks/explore.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,31 @@
}
}
},
{
"cell_type": "markdown",
"source": [
"### Testing for spatial correlation\n",
"\n",
"We can use a chi-squared test to check for evidence of spatial correlation between grid cell neighborhoods at any given length scale. We can first compute neighborhoods for each cell. Next we can retrieve for each cell the equiradial band of cells displaced from it by distance `d`, then compute the Hamming distance between the central cell's neighborhood and the neighborhood of each band cell. We compute this exhaustively for all possible values of `d` for a given grid size."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# TODO"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
Expand Down

0 comments on commit c3fbb68

Please sign in to comment.