You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use sources path attribute for docs/Project.toml
* Fix markdown lists in docstrings
* Add doctests
* Change to markdown admoniton block
* Change preformat list to markdown list
* Add syntax highlight tags
* Center block level latex math
* Use markdown URL link syntax
* Use unicode characters in tex sections
They're supported by KaTeX for web rendering, and the characters take up less space when viewing the docstring on REPL or so
* Fix up spacing in docstrings
* Add type header to docstrings
* Fix doctests in weights.md
Copy file name to clipboardExpand all lines: docs/src/weights.md
+23-17Lines changed: 23 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
```@meta
2
+
DocTestSetup = quote
3
+
using StatsBase
4
+
end
5
+
```
1
6
# Weight Vectors
2
7
3
8
In statistical applications, it is not uncommon to assign weights to samples. To facilitate the use of weight vectors, we introduce the abstract type `AbstractWeights` for the purpose of representing weight vectors, which has two advantages:
@@ -68,40 +73,42 @@ weights to past observations.
68
73
69
74
If `t` is a vector of temporal indices then for each index `i` we compute the weight as:
70
75
71
-
``λ (1 - λ)^{1 - i}``
76
+
```math
77
+
λ (1 - λ)^{1 - i}
78
+
```
72
79
73
80
``λ`` is a smoothing factor or rate parameter such that ``0 < λ ≤ 1``.
74
81
As this value approaches 0, the resulting weights will be almost equal,
75
82
while values closer to 1 will put greater weight on the tail elements of the vector.
76
83
77
84
For example, the following call generates exponential weights for ten observations with ``λ = 0.3``.
NOTE: This is equivalent to `eweights(something.(indexin(t, r)), 0.3)`, which is saying that for each value in `t` return the corresponding index for that value in `r`.
127
-
Since `indexin` returns `nothing` if there is no corresponding value from `t` in `r` we use `something` to eliminate that possibility.
133
+
!!! note
134
+
This is equivalent to `eweights(something.(indexin(t, r)), 0.3)`, which is saying that for each value in `t` return the corresponding index for that value in `r`.
135
+
Since `indexin` returns `nothing` if there is no corresponding value from `t` in `r` we use `something` to eliminate that possibility.
128
136
129
137
## Methods
130
138
131
139
`AbstractWeights` implements the following methods:
0 commit comments