I am a biology graduate student, and trying to code a certain behavior into a model in R, and having some "lost in translation" issues. The code I have follows the post. I am trying to model this system:
Imagine a bathtub with a vibrating marble. The surface of the bathtub is given by the function "bathtub". I want to find a way to: Simulate the vibration of the marble on the tub, given a "temperature" parameter. At low/zero temp., it should sit on the bottom, and as the temp. increases, it should explore higher up the sides. I want to store these in a vector and be able to see the path that a given realization of this stochastic process looks like.
My issue is figuring out not the function to describe the surface on which the marble is moving, but rather the probability of it being at any point on that surface given a starting value, time, and other parameters (curvature parameters a and b, temperature parameter, and maybe others).
I am basically looking for the analog to this code for the normal distribution:
bm <- function(x, x0, t, sigma) {
return(dnorm(x, mean=x0, sd=sigma*sqrt(t)))
}
Thanks so much for any ideas, code, or links to helpful resources.
BATHTUB#
##Loads packages
library(ggplot2) #for graphing purposes
##Defines the composite distribution bathtub, which is composed of two Beta distributions
bathtub <- function(b, a){
dbeta(x, 1, b) + dbeta(x, a, 1)
}
##Initiates the parameters.
b = 5 #How sharp the higher bound is
a = 20 #How sharp the lower bound is
x <- seq(0, 1, length=101) #high density sample of (0,1)
##Plots
bathtub <- bathtub(a,b) #R likes certain kinds of variables.
qplot(x, bathtub, geom="line") #Plots smooth function pdf(bathtub)
qplot(x, 1-bathtub, geom="line")#this is the "likelihood" function