{"id":18903781,"url":"https://github.com/bububa/timedecay","last_synced_at":"2025-08-02T00:40:44.433Z","repository":{"id":66891360,"uuid":"346243587","full_name":"bububa/timedecay","owner":"bububa","description":"Famous sorting algorithms based on vote popularity and time implemented for go","archived":false,"fork":false,"pushed_at":"2021-03-10T05:36:42.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T10:16:11.217Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bububa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-10T05:33:38.000Z","updated_at":"2021-03-10T05:36:44.000Z","dependencies_parsed_at":"2023-05-28T07:45:16.783Z","dependency_job_id":null,"html_url":"https://github.com/bububa/timedecay","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ftimedecay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ftimedecay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ftimedecay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Ftimedecay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bububa","download_url":"https://codeload.github.com/bububa/timedecay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239888303,"owners_count":19713690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T09:06:26.811Z","updated_at":"2025-02-20T17:45:50.888Z","avatar_url":"https://github.com/bububa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timedecay\n\nsorting algorithms implemented for go, based heavily on the nodejs implementation of [https://github.com/clux/decay](https://github.com/clux/decay)\n\nThis library houses 3 popularity estimating algorithms employed by bigger news sites used to sort for best content:\n\n  1. `WilsonScore` - Reddit's _best_ comment scoring system\n  2. `RedditHot` - Reddit's _hot_ post scoring system for news posts\n  3. `HackerHot` - Hackernews' scoring system\n\n![Wilson score equation](https://github.com/clux/decay/raw/master/rating-equation.png)\n\n## Usage\nDecay exports 3 scoring function factories.\n\nTwo of these algorithms decay with time, and the other is based purely on statistical popularity.\n\n### timedecay.NewWilsonScore(float64)\nNon-decay based calculation based on statistical confidence of data.\n```\nimport (\n    \"github.com/bububa/timedecay\"\n)\n\nfunc main() {\n    wilsonScore := timedecay.NewWilsonScore(1.96)\n    fmt.println(wilsonScore.Score(10, 3))\n}\n```\n\n### timedecay.NewRedditHot(float64)\nPopularity calcuation based on published Reddit rankings.  [http://amix.dk/blog/post/19588](http://amix.dk/blog/post/19588)\n```\nimport (\n    \"time\"\n\n    \"github.com/bububa/timedecay\"\n)\n\nfunc main() {\n    redditHot := timedecay.NewRedditHot(45000)\n    fmt.println(redditHot.Score(10, 3, time.now()))\n}\n```\n\n### timedecay.NewHackerHot(float64)\nPopularity calcuation based on published HackerNews rankings.  [http://amix.dk/blog/post/19574](http://amix.dk/blog/post/19574)\n```\nimport (\n    \"time\"\n\n    \"github.com/bububa/timedecay\"\n)\n\nfunc main() {\n    hackerHot := timedecay.NewHackerHot(1.9)\n    fmt.println(hackerHot.Score(10, 3, time.now()))\n}\n```\n\n## Parameter Explanation\n### 1. Wilson Score\nAKA Reddit's *[Best](http://blog.reddit.com/2009/10/reddits-new-comment-sorting-system.html)* comment sorting system. [Source](https://github.com/reddit/reddit/blob/bd922104b971a5c6794b199f364a06fdf61359a2/r2/r2/lib/db/_sorts.pyx#L70-L85)\n\nStatistically, it is the lower bound of the [Wilson Score interval](http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval) at the alpha level based on supplied Z score.\n\nThe optional `zScore` parameter can be passed as to the exported `wilsonScore` factory.\nThe Z score is a statistical value which roughly means how many standard deviations of safety you want, so it maps directly onto the confidence level of the Wilson Score interval.\n\nIt will default to `z=1.96` if left out, representing a `95%` confidence level in the lower bound. Otherwise, values through `1.0` (69%), to `3.3` (99.9%) good alternatives.\n\n### 2. Reddit Hot Sort\nBased on the difference between ups/downs, and decays with time. Causes hive mind effects in large crowds.\n\nAn optional _halflife_ parameter can be passed to the exported `redditHot` factory.\nThe half-life defaults to 45000 [s]. For info on the effects on this parameter read the original [blog post](https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9) about it. See also the canonical [reddit source version](https://github.com/reddit/reddit/blob/bd922104b971a5c6794b199f364a06fdf61359a2/r2/r2/lib/db/_sorts.pyx#L47-L58).\n\n### 3. HackerNews Hot Sort\nBased on simply the amount of upvotes, and decays with time. Prone to advertising abuse.\n\nAn optional `gravity` parameter (defaulting to `1.8`) can be passed to the exported `hackerHot` factory. For info on the effects of this parameter read the original [blog post](https://medium.com/hacking-and-gonzo/how-hacker-news-ranking-algorithm-works-1d9b0cf2c08d) about it.\n\n## Installation\n\n```bash\n$ go get -u github.com/bububa/timedecay\n```\n\n## License\nMIT-Licensed. See LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Ftimedecay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbububa%2Ftimedecay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Ftimedecay/lists"}