Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 2.0% on proxy.golang.org
Top 0.7% dependent packages on proxy.golang.org
Top 0.7% dependent repos on proxy.golang.org
Top 3.6% forks on proxy.golang.org
Top 1.7% docker downloads on proxy.golang.org

proxy.golang.org : github.com/mroth/weightedrand/v2

Package weightedrand contains a performant data structure and algorithm used to randomly select an element from some kind of list, where the chances of each element to be selected not being equal, but defined by relative "weights" (or probabilities). This is called weighted random selection. This package creates a presorted cache optimized for binary search, allowing for repeated selections from the same set to be significantly faster, especially for large data sets. In this example, we create a Chooser to pick from amongst various emoji fruit runes. We assign a numeric weight to each choice. These weights are relative, not on any absolute scoring system. In this trivial case, we will assign a weight of 0 to all but one fruit, so that the output will be predictable.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/mroth/weightedrand/v2
Keywords: go, golang, random, sampling, weighted-random
License: MIT
Latest release: 9 months ago
First release: over 1 year ago
Namespace: github.com/mroth/weightedrand
Dependent packages: 43
Dependent repositories: 65
Stars: 331 on GitHub
Forks: 46 on GitHub
Docker dependents: 4
Docker downloads: 42
See more repository details: repos.ecosyste.ms
Funding links: https://github.com/sponsors/mroth
Last synced: 1 day ago

    Loading...
    Readme
    Loading...