Why Biological Systems Suddenly Change State: An Intuitive Guide to Freidlin–Wentzell Theory

Image
  Stochasticity is ubiquitous in biology and neuroscience, manifesting in various forms, including ion channel noise, synaptic variability, gene regulatory fluctuations, noisy population dynamics, and more. Many biological systems spend long periods in a stable “state” and only rarely transition to another state due to noise. For instance, a neuron typically remains inactive but may occasionally trigger a spontaneous spike. Similarly, a gene can switch from the OFF state to the ON state due to rare bursts of transcription factors. Cells can also transition out of metabolic or epigenetic states, populations might shift between different ecological equilibria, and a viral infection can fluctuate between phases of control and uncontrollability. Freidlin–Wentzell theory provides a mathematically rigorous framework to study these phenomena when noise is small but nonzero . It tells you, firstly, h ow likely rare transitions are,    secondly,   h ow fast they occ...

R function ci_sigma

The function ci_sigma evaluates the  confidence interval of variance and standard deviation  for populations that are approximately normal. ci_sigma takes two arguments:

  • x: a vector of data.
  • alpha: significance level (default = 0.05).

The function checks if the input data is approximately normal using the Shapiro-Francia test from the nortest package. If the hypothesis of normality is not satisfied at the given significance level, it suggests trying a log-transformation and performs the Shapiro-Francia test again. If the hypothesis of normality is satisfied, it calculates critical values from the chi-squared distribution and uses them to calculate confidence intervals for both variance and standard deviation.

The function returns a list containing five elements:

  • VAR: variance of input data.
  • SD: standard deviation of input data.
  • CI.VAR: confidence interval for variance.
  • CI.SD: confidence interval for standard deviation.
  • dof: degrees of freedom.

Here is an example usage of this function:

x <- rnorm(100, mean = 10, sd = 2)

ci_sigma(x)


#CONFIDENCE INTERVAL OF STANDARD DEVIATION

#For populations that are approximately normal

ci_sigma<- function(x,alpha=0.05) {

  #x:          vector of data

  #alpha:      significance level (default=0.05)

 

  n<- length(x)

 

  #check normality

  library(nortest)

  out<-sf.test(x)

  out

 

  if(out$p.value<alpha) {

    print("the hypothesis of normality is not satisfied. Try log-trasformation")

    sf.test(log(x))

  } else {

    #critical values from the chi-squared distribution

    u.low<- qchisq(alpha/2,n-1,lower.tail=FALSE)

    u.up<- qchisq(1-alpha/2,n-1,lower.tail=FALSE)

   

    ci.var.low<- (n-1)*var(x)/u.low

    ci.var.up<- (n-1)*var(x)/u.up

   

    ci.var<- c(ci.var.low,ci.var.up)

    ci.std<- sqrt(ci.var)

   

    return(list(VAR=var(x),SD=sd(x),CI.VAR=ci.var,CI.SD=ci.std,dof=n-1))

  }

}

 


Comments

Popular posts from this blog

Understanding Anaerobic Threshold (VT2) and VO2 Max in Endurance Training

Owen's Function: A Simple Solution to Complex Problems

Cell Count Analysis with cycleTrendR