Skip to content

Commit

Permalink
Sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
nalimilan committed Sep 26, 2021
1 parent 8066ab2 commit 020a810
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 201 deletions.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ makedocs(
"robust.md",
"ranking.md",
"empirical.md",
"transformations.md"]
"transformations.md",
"sampling.md"]
)

deploydocs(
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ corrections where necessary.

```@contents
Pages = ["weights.md", "scalarstats.md", "cov.md", "robust.md", "ranking.jl",
"empirical.md", "transformations.md"]
"empirical.md", "transformations.md", "sampling.md"]
Depth = 2
```
8 changes: 4 additions & 4 deletions perf/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# require the BenchmarkLite package
using BenchmarkLite
using StatsBase
using Statistics

import StatsBase: direct_sample!, xmultinom_sample!
import StatsBase: knuths_sample!, fisher_yates_sample!, self_avoid_sample!
import StatsBase: seqsample_a!, seqsample_c!, seqsample_d!
import Statistics: direct_sample!, xmultinom_sample!
import Statistics: knuths_sample!, fisher_yates_sample!, self_avoid_sample!
import Statistics: seqsample_a!, seqsample_c!, seqsample_d!

### generic sampling benchmarking

Expand Down
8 changes: 4 additions & 4 deletions perf/wsampling.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Benchmark on weighted sampling

using BenchmarkLite
using StatsBase
using Statistics

import StatsBase: direct_sample!, alias_sample!, xmultinom_sample!
import Statistics: direct_sample!, alias_sample!, xmultinom_sample!

### procedure definition

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

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

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


# config is in the form of (n, k)
Expand Down
8 changes: 7 additions & 1 deletion src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ using Base: has_offset_axes, require_one_based_indexing

using Printf: @printf

import Random
using Random: Sampler, GLOBAL_RNG, AbstractRNG, randexp

export std, stdm, var, varm, mean!, mean,
median!, median, middle, quantile!, quantile,
# moments.jl
Expand Down Expand Up @@ -46,7 +49,9 @@ export std, stdm, var, varm, mean!, mean,
unnormalize, unnormalize!,
AbstractNormalization, MinMaxNormalization, ZScoreNormalization,
# reliability.jl
cronbachalpha, CronbachAlpha
cronbachalpha, CronbachAlpha,
# sampling.jl
sample, sample!, samplepair

include("common.jl")
include("weights.jl")
Expand All @@ -63,6 +68,7 @@ include("empirical.jl")
include("hist.jl")
include("transformations.jl")
include("reliability.jl")
include("sampling.jl")

##### mean #####

Expand Down
Loading

0 comments on commit 020a810

Please sign in to comment.