Skip to content

Commit 020a810

Browse files
committed
Sampling
1 parent 8066ab2 commit 020a810

File tree

9 files changed

+206
-201
lines changed

9 files changed

+206
-201
lines changed

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ makedocs(
1515
"robust.md",
1616
"ranking.md",
1717
"empirical.md",
18-
"transformations.md"]
18+
"transformations.md",
19+
"sampling.md"]
1920
)
2021

2122
deploydocs(

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ corrections where necessary.
1111

1212
```@contents
1313
Pages = ["weights.md", "scalarstats.md", "cov.md", "robust.md", "ranking.jl",
14-
"empirical.md", "transformations.md"]
14+
"empirical.md", "transformations.md", "sampling.md"]
1515
Depth = 2
1616
```

perf/sampling.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# require the BenchmarkLite package
44
using BenchmarkLite
5-
using StatsBase
5+
using Statistics
66

7-
import StatsBase: direct_sample!, xmultinom_sample!
8-
import StatsBase: knuths_sample!, fisher_yates_sample!, self_avoid_sample!
9-
import StatsBase: seqsample_a!, seqsample_c!, seqsample_d!
7+
import Statistics: direct_sample!, xmultinom_sample!
8+
import Statistics: knuths_sample!, fisher_yates_sample!, self_avoid_sample!
9+
import Statistics: seqsample_a!, seqsample_c!, seqsample_d!
1010

1111
### generic sampling benchmarking
1212

perf/wsampling.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Benchmark on weighted sampling
22

33
using BenchmarkLite
4-
using StatsBase
4+
using Statistics
55

6-
import StatsBase: direct_sample!, alias_sample!, xmultinom_sample!
6+
import Statistics: direct_sample!, alias_sample!, xmultinom_sample!
77

88
### procedure definition
99

@@ -28,10 +28,10 @@ mutable struct Direct_S <: WithRep end
2828
tsample!(s::Direct_S, wv, x) = sort!(direct_sample!(1:length(wv), wv, x))
2929

3030
mutable struct Sample_WRep <: WithRep end
31-
tsample!(s::Sample_WRep, wv, x) = sample!(1:length(wv), wv, x; ordered=false)
31+
tsample!(s::Sample_WRep, wv, x) = sample!(1:length(wv), x; weights=wv, ordered=false)
3232

3333
mutable struct Sample_WRep_Ord <: WithRep end
34-
tsample!(s::Sample_WRep_Ord, wv, x) = sample!(1:length(wv), wv, x; ordered=true)
34+
tsample!(s::Sample_WRep_Ord, wv, x) = sample!(1:length(wv), x; weights=wv, ordered=true)
3535

3636

3737
# config is in the form of (n, k)

src/Statistics.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ using Base: has_offset_axes, require_one_based_indexing
1414

1515
using Printf: @printf
1616

17+
import Random
18+
using Random: Sampler, GLOBAL_RNG, AbstractRNG, randexp
19+
1720
export std, stdm, var, varm, mean!, mean,
1821
median!, median, middle, quantile!, quantile,
1922
# moments.jl
@@ -46,7 +49,9 @@ export std, stdm, var, varm, mean!, mean,
4649
unnormalize, unnormalize!,
4750
AbstractNormalization, MinMaxNormalization, ZScoreNormalization,
4851
# reliability.jl
49-
cronbachalpha, CronbachAlpha
52+
cronbachalpha, CronbachAlpha,
53+
# sampling.jl
54+
sample, sample!, samplepair
5055

5156
include("common.jl")
5257
include("weights.jl")
@@ -63,6 +68,7 @@ include("empirical.jl")
6368
include("hist.jl")
6469
include("transformations.jl")
6570
include("reliability.jl")
71+
include("sampling.jl")
6672

6773
##### mean #####
6874

0 commit comments

Comments
 (0)