# Given unnormalized weights in logs, how do I compute normalized weights in logs?

by bamts   Last Updated November 08, 2018 23:19 PM

## Basics

Given a set of nonnegative weights $$\{w_i\}_{i=1}^n$$, I can normalize them by computing $$W_i = \frac{w_i}{\sum_{j=1}^nw_j}\quad \forall i=1,...,n.$$ Easy enough. But for numerical reasons, it is good to work in logs.

## Question

Given the set of unnormalized weights in logs $$\{\ln w_i\}_{i=1}^n$$, what's the best way to compute the set of normalized weights in logs $$\{\ln W_i\}_{i=1}^n$$?

## Naive Approach

Given $$\{\ln w_i\}_{i=1}^n$$, I can obviously recover the $$w_i$$ by exponentiating the $$\ln w_i$$, and from there I can compute $$\ln W_i = \ln w_i - \ln\left[\sum_{j=1}^nw_j\right]\quad \forall i = 1,...,n.$$ Can I do better? Is it possible to compute the $$\ln W_i$$ without exponentiating the $$\ln w_i$$?

Tags :