roqua / physiqual

Ruby Engine for merging various datasources with diary questionnaire data
MIT License
1 stars 1 forks source link

Implement better tie-breaking scheme for soft histogram #8

Closed frbl closed 8 years ago

frbl commented 9 years ago

Op dit moment wordt heartrate nog as-is van de api gereturned. Implementeer histrogram sampling om de meestvoorkomende heartrate te samplen van een persoon. Het histogram zoals we besproken hebben is niet een traditioneel histogram, maar een soort soft histogram implementatie, waarbij niet alleen de frequentie in de huidige bucket wordt berekend, maar ook de n omliggende buckets worden verhoogd. I.e., als n = 2, en er wordt een hartslag van 70 gemeten, dan wordt bucket 70 verhoogd, maar ook bucket 68, 69, 71 en 72.

We zouden nog een weight hieraan kunnen toevoegen, i.e.,

1 - (x-i) / n

waarbij x het geselecteerde bucket is (70), en i een van de omliggende buckets.

frbl commented 9 years ago

De manier zonder de weights is geimplementeerd in #9

emerencia commented 9 years ago

I see no benefit of adding weights. The existing code is not efficient but works. However, in case of a tie, there is no guarantee that we return a value that was measured even once. Consider the following alternative tie-breaking scheme:

The returned heart rate is the maximum value of the windowed histogram technique. In case of a tie, we choose the value that lies closest to their mean. When there are two such values, we return the maximum of the two.

emerencia commented 8 years ago

Fixed in #49.