spatial_stats 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spatial_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Doggett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-29 00:00:00.000000000 Z
11
+ date: 2020-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -129,8 +129,8 @@ files:
129
129
  - lib/spatial_stats/global/stat.rb
130
130
  - lib/spatial_stats/local.rb
131
131
  - lib/spatial_stats/local/bivariate_moran.rb
132
- - lib/spatial_stats/local/g.rb
133
132
  - lib/spatial_stats/local/geary.rb
133
+ - lib/spatial_stats/local/getis_ord.rb
134
134
  - lib/spatial_stats/local/moran.rb
135
135
  - lib/spatial_stats/local/multivariate_geary.rb
136
136
  - lib/spatial_stats/local/stat.rb
@@ -150,7 +150,8 @@ files:
150
150
  homepage: https://www.github.com/keithdoggett/spatial_stats
151
151
  licenses:
152
152
  - MIT
153
- metadata: {}
153
+ metadata:
154
+ documentation_uri: https://keithdoggett.github.io/spatial_stats/docs/index.html
154
155
  post_install_message:
155
156
  rdoc_options: []
156
157
  require_paths:
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SpatialStats
4
- module Local
5
- class G < Stat
6
- def initialize(scope, field, weights, star = false)
7
- super(scope, field, weights)
8
- @star = star
9
- end
10
- attr_accessor :star
11
- attr_writer :x, :z_lag
12
-
13
- def i
14
- x.each_with_index.map do |_x_val, idx|
15
- i_i(idx)
16
- end
17
- end
18
-
19
- def i_i(idx)
20
- x_lag[idx] / denominators[idx]
21
- end
22
-
23
- def x
24
- @x ||= SpatialStats::Queries::Variables.query_field(@scope, @field)
25
- end
26
- alias z x
27
-
28
- def star?
29
- @star ||= weights.full.trace.positive?
30
- end
31
-
32
- private
33
-
34
- def w
35
- @w ||= begin
36
- if star?
37
- # TODO: try to fix this because it will still likely be a
38
- # bottleneck in mc testing
39
- weights.full.windowed.row_standardized
40
- else
41
- weights.standardized
42
- end
43
- end
44
- end
45
-
46
- def z_lag
47
- # window if star is true
48
- @z_lag ||= begin
49
- if star?
50
- SpatialStats::Utils::Lag.window_sum(w, x)
51
- else
52
- SpatialStats::Utils::Lag.neighbor_sum(w, x)
53
- end
54
- end
55
- end
56
- alias x_lag z_lag
57
-
58
- def denominators
59
- @denominators ||= begin
60
- n = w.shape[0]
61
- if star?
62
- [x.sum] * n
63
- else
64
- # add everything but i
65
- (0..n - 1).each.map do |idx|
66
- terms = x.dup
67
- terms.delete_at(idx)
68
- terms.sum
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end