Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bin and reduce

Aperta
#893 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
julia
Ambito
data

Direzione di ricerca

Esamina lo schema proposto binned(x, y, bins, μ, Ε), usando fit(Histogram) e StatsBase.binindex come punti di ingresso indicati. Confronta il raggruppamento 2D richiesto e l’output degli intervalli di confidenza con le API esistenti di StatsBase, quindi aggiungi test mirati per input di uguale lunghezza, bins vuoti e la tupla restituita; nell’issue non è indicato alcun file di test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I very regularly want to bin some 2D data based on the first element and then apply a grouping function to the 2nd element.

I wrote this for 2D case, but I have similar functions for the 3D case (bin on x,y and apply function to z)

"""
`binned(x,y,bins, μ, Ε)`

Takes vectors `x,y` of equal length than bins `x` according to `bins`. Apply `µ,E` (often mean) to `y` grouped by bins of `x`.

`µ` is any function that takes a vector and return a number (usually `mean`)
`E` is any function that takes a vector and returns a 2-element iterable, which represent the lower and upper CI for that bin.

Returns a 3-tuple with `(bin_c,  µ_y, E_y)` such that you can plot the results with `plot(bin_c, µ_y, yerr=E_y)`
"""
binned(x,y, bins, μ, Ε) = begin
   @assert length(x) == length(y)
    h = fit(Histogram, x, bins)

    ox = (bins[1:end-1] + bins[2:end])/2
    xmap = StatsBase.binindex.(Ref(h), x)

    oy = [sum(z.==xmap) > 0 ? μ(y[z.==xmap]) : NaN for z in 1:length(ox)]
    oe = [sum(z.==xmap) > 0 ? Ε(y[z.==xmap]) : [NaN, NaN] for z in 1:length(ox)]
    # This returns a long list of 2-tuples, but we want a 2-tuple of vectors
    (ox, oy, 	(oy .- (x->x[1]).(oe), (x->x[2]).(oe) .- oy))
end

would something like this (but cleaned up/tested/etc) fit into StatsBase?

Lingua principale
Julia
Stelle
614
Fork
197
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaStats/StatsBase.jl

Tutte le issue di JuliaStats/StatsBase.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.