convolutionalfixedsum

ConvolutionalFixedSum Algorithm

https://github.com/dgdguk/convolutionalfixedsum

Science Score: 31.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

ConvolutionalFixedSum Algorithm

Basic Info
  • Host: GitHub
  • Owner: dgdguk
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Size: 65.4 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

ConvolutionalFixedSum

ConvolutionalFixedSum is an algorithm for generating vectors of random numbers such that:

  1. The values of the vector sum to a given total U
  2. Given a vector of upper constraints, each element of the returned vector is less than or equal to its corresponding upper bound
  3. Given a vector of lower constraints, each element of the returned vector is greater or equal to than its corresponding lower bound
  4. The distribution of the vectors in the space defined by the constraints is uniform.

This algorithm was developed when the authors found that their prior work, the Dirichlet-Rescale Algorithm (DRS), did not, in fact generate values uniformly. As such, ConvolutionalFixedSum supercedes the DRS algorithm.

Usage

Two implementations of ConvolutionalFixedSum are provided: an analytical method, cfsa, which scales exponentially with the length of the vector $n$ and is subject to floating point error, and the recommended numerical approximation cfsn which scales polynomially with $n$. cfsa can be useful for $n \leq 15$, while cfs should work well for larger n. See the paper for a full discussion on this aspect.

Below are some examples on how to use the library.

```python from convolutionalfixedsum import cfsa, cfsn

Generate 3 random values which sum to 2.0, are bounded below by 0 and above by 1

cfsn(3, total=2.0)

Generate 3 random values which sum to 1.0, and whose upper constraints are [1.0, 0.5, 0.1] respectively

cfsn(3, upper_constraints=[1.0, 0.5, 0.1])

Same as before, but the middle value can not be lower than 0.3

cfsn(3, lowerconstraints=[0.0, 0.3, 0.0], upperconstraints=[1.0, 0.5, 0.1])

cfsa has basically the same function signature for most uses

cfsa(3, lowerconstraints=[0.0, 0.3, 0.0], upperconstraints=[1.0, 0.5, 0.1]) ```

Citation

If you wish to cite this software package, use the cite this repository feature of Github. It can give citation data in a variety of formats.

If you wish to cite the underlying research, please cite the following paper (Bibtex only, DOI after proceedings are published).

bibtex @inproceedings{Griffin2025, title={ConvolutionalFixedSum: Uniformly Generating Random Values with a Fixed Sum Subject to Arbitrary Constraints}, author={Griffin, David and Davis, Robert I.}, booktitle={31st {IEEE} Real-Time and Embedded Technology and Applications Symposium}, year={2025}, }

Owner

  • Login: dgdguk
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Griffin"
  given-names: "David"
  orcid: "https://orcid.org/0000-0002-4077-0005"
- family-names: "Davis"
  given-names: "Robert I."
  orcid: "https://orcid.org/0000-0002-5772-0928"
title: "ConvolutionalFixedSum Software"
version: 0.0.1
doi: 10.5281/zenodo.15107012
date-released: 2025-03-29
url: "https://github.com/dgdguk/convolutionalfixedsum/"

GitHub Events

Total
  • Create event: 4
  • Issues event: 1
  • Release event: 2
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 7
  • Pull request event: 2
Last Year
  • Create event: 4
  • Issues event: 1
  • Release event: 2
  • Watch event: 1
  • Issue comment event: 1
  • Push event: 7
  • Pull request event: 2

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 1
  • Total pull requests: 2
  • Average time to close issues: about 14 hours
  • Average time to close pull requests: less than a minute
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: about 14 hours
  • Average time to close pull requests: less than a minute
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • dgdguk (1)
Pull Request Authors
  • dgdguk (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 314 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
pypi.org: convolutionalfixedsum

Algorithm to generate uniformly sampled random vectors which sum to a given value, with constraints on each variate

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 314 Last month
Rankings
Dependent packages count: 9.2%
Forks count: 31.5%
Average: 33.4%
Stargazers count: 41.4%
Dependent repos count: 51.7%
Maintainers (1)
Last synced: 10 months ago

Dependencies

requirements-testing.txt pypi
  • Drs * test
  • colorcet * test
  • matplotlib * test
  • pyvista * test
  • scipy * test
  • tqdm * test
requirements.txt pypi
  • cffi *
  • numpy *
  • scipy *
  • setuptools *