Sampling from discrete distribution and prior sensitivities
- Dominant language
- C++
- Stars
- 607
- Forks
- 67
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
Hi and thank you for the awesome package!
_**The following are really really silly questions related to non-standard use of the package. Please, feel free to close this issue as "off-topic".**_
I am thinking of using `greta` for decision analysis. Lets say we have uncertain price of an asset and discrete possible acquired stake 0, 50% or 100%. I want to simulate the deal value (The distribution itself does not mean much).
```r
library(greta)
# yay, I can define some sensitivities
price = normal(c(2,3),c(1,3))
probs <- c(0.4, 0.35, 0.25)
cps <- cumsum(c(0, probs[-3]))
# Vector of possible acquired stakes
# p <- c(0, 0.5, 1)
# with probabilities probs
i = sum(uniform(0,1)>= cps)
s =(i-1)/2
# deal_value = price * stake
vn = price*s
m <- model(price, s, vn)
draws <- mcmc(m, n_samples = 1000)
## ggplot2 code for plotting ecdf
```

It seems like I can simulate several priors and (with some rearranging) plot and compare them. Not sure how this would go if I wanted to run alternative prior (different distribution, not just different parameters). What do you think my approach should be?
I tried very hard to sample from discrete distribution. My object `i` contains indices to the vector of discrete values `p`, but I can't use subsetting to "look it up". I am doing some math in `s`, but that is just a numerical coincidence. What is the best way to use simulated values for subsetting? What if I define my `p` as `greta.array`, would I be able to subset it with simulated values in `i`?
Finally, entirely stupid question regarding channels: can I use them for sensitivities (i.e. alternative priors or other parameters for simulation).
I have not gotten into likelihoods yet, but I would eventually like to be able to update discrete priors with discrete likelihoods and sample from the resulting posterior.
Contributor guide
Assessment
This issue has not been assessed yet.