JuliaGaussianProcesses / JuliaGaussianProcesses/ParameterHandling.jl

A vector, where all elements are bounded between 0 and 1, and sum(vector)=1.

Open
#56 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
74
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Love the package.

I often have components of models where I need to parameterize a categorical probability distribution. I use the following trick:

σ(z::Real) = one(z) / (one(z) + exp(-z))
function unconstrained2probvec(v)
    l = length(v)
    remaining = 1.0
    o = zeros(l+1)
    for i in 1:l
        #log(l+1-i) is a "balancing" shift to ensure that a vector of zeros givens you [1/N ... 1/N]
        o[i] = remaining*σ(v[i] - log(l+1-i))
        remaining -= o[i]
    end
    o[end] = max(0.0,remaining)
    return o
end

This takes a vector of N-1 unbounded values and returns a vector of N values, bounded between 0 and 1, that sums to 1. When input is all zeros, the output is all 1/N.

I'm too stupid to figure out how to build this into your package, but if you think it would be sensible to do so, please consider this a feature request.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by reviewing the package's existing parameter-handling and transformation APIs, then determine where a simplex-valued parameter belongs and what tests would establish bounded elements, a unit sum, and equal values for an all-zero input.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.