I have multiple distribution functions, lets say:
A <- function(x)dnorm(x, mean = 3, sd = 1)
B <- function(x)dnorm(x, mean = 6, sd = 1)
C <- function(x)dnorm(x, mean = 2, sd = 2)
I would like to create a new, proportional distribution function. For the three functions above, using the pdqr package, I can write this:
x <- seq(1, 10, by = 0.1)
P <- data.frame(x) %>%
mutate(A = A(x),
B = B(x),
C = C(x)) %>%
mutate(y = A * B * C) %>%
pdqr::new_d(type = "continuous")
This generates the proportional distribution P shown below, based on A, B and C.

Now, since it is a drag to create new distribution functions based on a range of 2 to 10 other distributions, I would like to create a function, which takes a list of distributions to create a new proportional distribution function. Ideally, it would take this input: P <- foo(c(A, B, C))
However, I can't seem to get any further than:
foo <- function(list){
#set x values
x <- seq(1, 10, by = 0.1)
#create new function
data.frame(x) %>%
for(i in list){
mutate(i = i(x))%>%
mutate(y = i * i) %>%
new_d(type = "continuous")
}
}
Which obviously doesn't work. The question is twofold: how to pass the functions in the list to:
- create new vectors to calculate the propability for each
x - to create a
ywhich multiplies the values generated in step 1