-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improve docs * Update api.md
- Loading branch information
Showing
8 changed files
with
143 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# API | ||
|
||
## General functionalities | ||
|
||
```@docs | ||
ReservoirSample | ||
update! | ||
value | ||
ordered_value | ||
itsample | ||
``` | ||
|
||
# Algorithms | ||
|
||
```@docs | ||
StreamSampling.algL | ||
StreamSampling.algR | ||
StreamSampling.algRSWRSKIP | ||
StreamSampling.algAExpJ | ||
StreamSampling.algARes | ||
StreamSampling.algWRSWRSKIP | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
# API | ||
|
||
## General functionalities | ||
# Introduction | ||
|
||
This package allows to sample from any stream in a single pass through the data, even if the number of items is unknown. | ||
|
||
If the iterable is lazy, the memory required grows in relation to the size of the sample, instead of the all population, which can be useful for sampling from big data streams. | ||
|
||
# Example Usage | ||
|
||
The [`itsample`](@ref) instead allows to consume all the stream at once and return the sample collected: | ||
|
||
```@docs | ||
itsample | ||
``` | ||
julia> using StreamSampling | ||
julia> st = 1:10; | ||
# Implemented ALgorithms | ||
julia> itsample(st, 5) | ||
5-element Vector{Int64}: | ||
9 | ||
15 | ||
52 | ||
96 | ||
91 | ||
``` | ||
In some cases, one needs to control the updates the [`ReservoirSample`](@ref) will be subject to. In this case | ||
you can simply use the [`update!`](@ref) function to fit new values in the reservoir: | ||
|
||
```@docs | ||
StreamSampling.algL | ||
StreamSampling.algR | ||
StreamSampling.algRSWRSKIP | ||
StreamSampling.algAExpJ | ||
StreamSampling.algARes | ||
StreamSampling.algWRSWRSKIP | ||
``` | ||
julia> using StreamSampling | ||
julia> rs = ReservoirSample(Int, 5); | ||
julia> for x in 1:100 | ||
@inline update!(rs, x) | ||
end | ||
julia> value(rs) | ||
5-element Vector{Int64}: | ||
7 | ||
9 | ||
20 | ||
49 | ||
74 | ||
``` | ||
|
||
Consult the [API page](https://juliadynamics.github.io/StreamSampling.jl/stable/api/) for more information on the available functionalities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters