Displaying 2 results from an estimated 2 matches for "sigma_pos".
2006 Sep 22
4
Creating Movies with R
...t:
rm(list=ls())
library(lattice)
# I start defining the analytical functions needed to get the density
as a function of time
expect_position <- function(t,lam1,lam2,pos_ini,vel_ini)
{1/(lam1-lam2)*(lam1*exp(lam2*t)-lam2*exp(lam1*t))*pos_ini+
1/(lam1-lam2)*(exp(lam1*t)-exp(lam2*t))*vel_ini
}
sigma_pos<-function(t,q,lam1,lam2)
{
q/(lam1-lam2)^2*(
(exp(2*lam1*t)-1)/(2*lam1)-2/(lam1+lam2)*(exp(lam1*t+lam2*t)-1) +
(exp(2*lam2*t)-1)/(2*lam2) )
}
rho_x<-function(x,expect_position,sigma_pos)
{
1/sqrt(2*pi*sigma_pos)*exp(-1/2*(x-expect_position)^2/sigma_pos)
}
#### Now the physical parameters
ta...
2006 Oct 03
1
do.call with Vectorial Argument
...kage).
Consider the small script:
remove(list=ls())
#library(adapt)
# first a list of the parameters
tau<-0.1
beta<-1/tau
St<-tau
D=2e-2
q<-2*beta^2*D
lam1<- -beta/2*(1+sqrt(1-4*St))
lam2<- -beta/2*(1-sqrt(1-4*St))
x0<- 0
vx0<- 1
# fist a function with scalar parameters
sigma_pos_old<-function(t,q,lam1,lam2)
{
q/(lam1-lam2)^2*(
(exp(2*lam1*t)-1)/(2*lam1)-2/(lam1+lam2)*(exp(lam1*t+lam2*t)-1) +
(exp(2*lam2*t)-1)/(2*lam2) )
}
# now the same function where the only argument t is given as a 1x1 vector
sigma_pos<-function(myargs)
{
q/(lam1-lam2)^2*(
(exp(2*lam1*myargs[1])...