0

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 
  • 2
    Parameters: starting location, temperature, "maybe others"? You haven't really figured out what mathematical or physical model to use, but you want us to both define it and then code it for you? Seems like _you_ first need to define your model (perhaps by doing your "homework" studying some differential equation text). Then it will be become a coding problem. – IRTFM Aug 10 '14 at 16:07
  • @BondedDust Lighten up a little; it's useless to make negative assumptions and then whine about your imagined scenario. If you don't have any constructive comments then just stay out of it. Sheesh. – Robert Dodier Aug 10 '14 at 20:31

1 Answers1

1

I'm guessing that you're not actually studying bathtubs -- maybe it will help others understand what's going on if you say what the actual topic is.

I can see at least two directions to go, based on the existing description.

(1) Model the motion of a marble using differential equations. You can probably get all kinds of interesting effects -- for some combinations of parameters, the marble gains kinetic energy and eventually shoots out of the bathtub; for others, the motion is periodic; for still others, the motion is chaotic. That could be fascinating, but I'm guessing it's much more detail than you really need.

(2) Ignore the actual mechanics and pretend the marble is an atom in Brownian motion on the surface of the bathtub. Increased temperature makes the atom's jiggles larger. This scenario is probably much easier to analyze; it is probably a solved problem in statistical mechanics. It is reminiscent of Markov chain Monte Carlo algorithms as well.

Good luck and have fun; sound like an interesting problem.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • It might be interesting. But is it a coding problem, ...yet? And does this constitute an answer? I would say 'no' to both questions. – IRTFM Aug 11 '14 at 03:35