Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

bin and reduce

オープン
#893 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
julia
領域
data

調査の方向性

fit(Histogram) と StatsBase.binindex を名前付きのエントリポイントとして使用し、提案されている binned(x, y, bins, μ, Ε) スケッチをレビューしてください。要求されている 2D グループ化と信頼区間の出力を既存の StatsBase API と比較し、その後、同じ長さの入力、空の bins、返されるタプルを対象とした集中的なテストを追加してください。issue ではテストファイルは指定されていません。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Julia
スター
614
フォーク
197
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaStats/StatsBase.jl のほかの issue

JuliaStats/StatsBase.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。