Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Dirichlet distribution #62

Open
VictorvanRoey opened this issue Feb 23, 2023 · 7 comments
Open

Error with Dirichlet distribution #62

VictorvanRoey opened this issue Feb 23, 2023 · 7 comments

Comments

@VictorvanRoey
Copy link

Using the dirichlet distribution in a three-arm node keeps giving the error that the sum of probabilities does not equal 1. I included the dirichlet distribution as Dir([7, 2,1], ~) as a parameter. Then I included the probabilities as a subset of the parameter for all three arms i.e. parameter[0], parameter[1], parameter[2].

Initially this works, however, when performing a PSA it keeps giving the abovementioned error. Can I fix this error or is this a problem with the software?

@VictorvanRoey
Copy link
Author

The error log did not include any errors:

Version: 0.3.0

Errors (0):


System properties
Java Runtime Environment version: 1.8.0_333
Java Runtime Environment vendor: Oracle Corporation
Java vendor URL: http://java.oracle.com/
Java installation directory: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Java Virtual Machine specification version: 1.8
Java Virtual Machine specification vendor: Oracle Corporation
Java Virtual Machine specification name: Java Virtual Machine Specification
Java Virtual Machine implementation version: 25.333-b02
Java Virtual Machine implementation vendor: Oracle Corporation
Java Virtual Machine implementation name: Java HotSpot(TM) 64-Bit Server VM
Java Runtime Environment specification version: 1.8
Java Runtime Environment specification vendor: Oracle Corporation
Java Runtime Environment specification name: Java Platform API Specification
Java class format version number: 52.0
Java class path: Amua-0.3.0.jar
Default temp file path: /var/folders/y8/97rs5kgj3blcqbpwd0b8m5w40000gn/T/
Name of JIT compiler to use: null
Operating system name: Mac OS X
Operating system architecture: x86_64
Operating system version: 13.1
Heap - Used Memory: 12 MB
Heap - Total Memory: 245 MB
Heap - Max Memory: 3641 MB
Available Processors: 8
Screen Resolution: 128
Screen Size: java.awt.Dimension[width=1440,height=900]

@RiversPharmD
Copy link

I think this is a challenge with drichlet distributions in PSAs. This error means youre getting three values either greater than 1 or less than 1. I'm not sure how it's being written here, I'll leave that to the other Zach. When I use them, I sample two of the three parameters, and then set the parameter[2] = MAX(0, 1-(parameter[0]+parameter[1])). I usually end up turning my three-branch nodes into a nested two-branch->two-branch node.

If the three node model has probabilities p0=0.75, p1=0.15, and p2=0.1, my first node ends up having probabilities 0.75(p0) and 0.25(1-p0). the p0 arm gets extended by one length, and then the 1-p0 arm has a node with probabilities 0.6(p1/p1+p2) and 0.4(p2/p1+p2).

@zward
Copy link
Owner

zward commented Feb 23, 2023

This might be a finite-precision rounding issue, with the 3 sampled probabilities not summing close enough to 1.0 (slightly above or below). Have you tried using 'C' as one of the branch probabilities? ('C' stands for ‘complementary’ probability and will ensure that all branches sum to 1.0, as long as the other two sum to <=1.0)

@zward
Copy link
Owner

zward commented Feb 23, 2023

@VictorvanRoey
Copy link
Author

Thank you for your responses! It is not a problem with precision rounding issues, since the sum of probabilities is sometimes quite different from 1 (e.g. >2 or <0.8). Using the C does not work.

I think that the problem is that the uncertainty around the three probabilities allow the sum of probabilities to exceed 1. However, in theory this should be prevented with the dirichlet distribution, but this does not work.
It seems that the probabilities from the dirichlet distribution in the PSA are sampled independently instead of simultaneous, making it possible for the sum to be not equal to 1.

I have also tried the nested two-branch -> two-branch node as suggested by RiversPharmD, but this does only work if you have discrete values for the probabilities without uncertainty. I have also tried the nested two-branch node together with the Dirichlet distribution to see if that would work and solve rounding issues, but it does not too. It just seems to be a problem with sampling of the dirichlet distribution in PSA.

@zward
Copy link
Owner

zward commented Feb 24, 2023

I'm able to run a PSA sampling from a Dirichlet - see a simple example below. The parameter 'dir' is defined as "Dir([7, 2, 1], ~)".
Are you able to replicate this example?

image

@VictorvanRoey
Copy link
Author

Although I got the error message about the sum of probabilities that were related to the ditrichlet distribution, that was not the problem at all. The problem lies in the constraints. Even though it is weird that the constraints in question have nothing to do with the probabilities of the ditrichlet distribution. Perhaps a good thing to know for other people that face errors when using the ditrichlet distribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants