math icon indicating copy to clipboard operation
math copied to clipboard

A log_add_exp function that returns containers

Open WardBrian opened this issue 1 year ago • 6 comments
trafficstars

It would be nice to have a function that works like log_sum_exp but elementwise, so the return was also a container.

I have a similar issue with log_sum_exp where I wanted it to vector[n] a = log_sum_exp(vector[n] b, vector[n] c) across each element, however it doesn't do this type of elementwise sum. Maybe if we had a log_add_exp which I've seen in other languages.

Originally posted by @spinkney in https://github.com/stan-dev/docs/issues/832#issuecomment-2478728469

WardBrian avatar Nov 15 '24 14:11 WardBrian

Hi, can I be assigned this issue?

MichaScant avatar Nov 17 '24 22:11 MichaScant

Hi @MichaScant -- we don't really use the 'assign' feature of GitHub, but if you want to go ahead and tackle this, feel free!

WardBrian avatar Nov 18 '24 14:11 WardBrian

@WardBrian we have a log_diff_exp. Should we also add a log_subtract_exp?

spinkney avatar Nov 18 '24 14:11 spinkney

@spinkney if it would be useful, but probably easiest to have as a separate issue

WardBrian avatar Nov 18 '24 15:11 WardBrian

Hello, I am in the middle of building the test file using log_sum_exp_test as an example and noticed you were passing in logSumExp into the test

Screenshot 2024-11-22 at 7 28 25 PM

Would I have to initialize an equivalent logAddExp and how would that occur? Or is there a substitute I can use? Thank you

MichaScant avatar Nov 23 '24 00:11 MichaScant

The two arguments there are test group and test name, so you can just write the logAddExp without having to do any more code

WardBrian avatar Nov 23 '24 01:11 WardBrian