[Feature Request] `Frequency` merge operations
@bvenn ci sta già lavorando.
Dal 26/4/2023.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Merge operations for Maps
Data can be sorted into bins of predefined width using the Frequency or EmpiricalDistribution module. If two datasets are binned and should be merged afterwards, several merging strategies are possible. A simple merge of freqA and freqB is straightforward with keys that are present in freqA and freqB are replaced with the values of freqB.
let a =
[("k1",1);("k2",3)]
|> Map.ofList
let b =
[("k2",1);("k3",4)]
|> Map.ofList
merge a b
results in the following combination with ("k2",3) from a being replaced by ("k2",1) from b:
val it: Map<float,int> = map [("k1", 1); ("k2", 1); ("k3", 4)]
Generic formulation of merge operations
I'm in the process of adding a generic function that gets an additional function that handles key duplicates. E.g.:
add a b
resulting in the combination of a and b with ("k2",3) from a being added to ("k2",1) from b:
val it: Map<float,int> = map [("k1", 1); ("k2", 4); ("k3", 4)]
While this is trivial, I'm not sure how to handle a subtraction. Should the result from subtract a b result in:
- a)
val it: Map<float,int> = map [("k1", 1); ("k2", 2); ("k3", 4)]- counts from
aare subtracted by the corresponding values frombif keys are present in both maps - here the values of
athat are not present inbare untouched
- counts from
- b)
val it: Map<float,int> = map [("k1", 1); ("k2", 2); ("k3", -4)]- counts from
aare subtracted by the values fromb, even for keys that are not present ina
- counts from
The latter option (b) makes no sense to me since frequency counts should not be negative, but I cannot think of applications in which the result of (a) makes any sense. Maybe the subtract function is not the best to start with because in this post they implemented (a) with addition and multiplication examples. Especially for the addition, a and b would give the correct result and I think it is intuitive to just apply the function to values of keys that are present in both maps.
@HarryMcCarney, do you know use cases that use subtract? Do you have any thoughts about this? I would suggest to add version (a) to Frequency as well as EmpiricalDistribution
Additional remark: When applied to continuous data bandwidths must be equal, to not merge counts from overlapping bins!
- Lingua principale
- F#
- Stelle
- 228
- Fork
- 58
- Merge medio
- 2g 7h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fslaborg/FSharp.Stats
-
Documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fslaborg/FSharp.Stats#385 · 2 commenti ·
-
automation Documentation repo-assist
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
fslaborg/FSharp.Stats#390 ·
-
automation Documentation repo-assist
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 1/100
fslaborg/FSharp.Stats#382 ·
-
question
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
fslaborg/FSharp.Stats#355 · 18 commenti ·
-
enhancement needs investigation
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
fslaborg/FSharp.Stats#344 · 4 commenti ·