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: calculate the anaerobic threshold

RunTime <- function(Time,Distance,Distance_reference,bpm) {

## INPUT

#Time: run time measured [min, s]

#Distance: run distance [mt]

#Distance_reference: reference distance [mt] of which we want to evaluate the expected time 

#bpm: cardiac frequency (beats per minute) 

## OUTPUT

# T2 = tempo corsa atteso su distanza di riferimento (s)

# V2 = velocità attesa su distanza di riferimento (km / h)

# V1 = velocità media singole corse (km / h)

# Vm = velocità media su distanze e tempi rilevati cumulati (km / h)

# FC = Frequenza cardiaca per minuto

# SAN = Soglia Anaerobica stimata

# SAN2 = proiezione Soglia Anaerobica su tempi attesi e distanza di riferimento

# D1 = distanze percorse

# P1 = passo corsa per km [min, s]  

# P2 = passo corsa atteso per km [min, s]  


T1 <- Time

D1 <- Distance

D2 <- Distance_reference

T = T1[,2] + T1[,1]*60 # run time (seconds)

T2 = T* (D2/D1)^(1.06) # expected time (seconds)

V2 = 3.6 * (D2/T2)

V1 = 3.6 * (D1/T);

p = (1000*T/D1)/60 # run pace per km 

P1 = data.frame(floor(p), ((p - floor(p))*60)) # run pace per km [min, s]  

p2 = (1000*T2/D2)/60 # expected run pace per km 

P2 = data.frame(floor(p2), ((p2 - floor(p2))*60)) # expected run pace per km [min, s]  

Vm = 3.6 * (sum(D1)/sum(T));

SAN = 35000/(T*(10000/D1)) #Anaerobic Threshold

SAN2 = 35000/(T2*(10000/D2)) #projection of the Anaerobic Threshold over expected time and reference distance

FC <- bpm

## summary statistics

stats=NULL

stats$V1 = c(mean(V1), sd(V1))

stats$D1 = c(mean(D1), sd(D1))

stats$V2 = c(mean(V2), sd(V2))

stats$T1 = c(mean(T), sd(T))

stats$T2 = c(mean(T2), sd(T2))

stats$SAN = c(mean(SAN), sd(SAN))

stats$SAN2 = c(mean(SAN2), sd(SAN2))

stats$FC = c(mean(FC), sd(FC))

stats$P1 = c(mean(p), sd(p))

stats$P2 = c(mean(p2), sd(p2))

DF <- data.frame(

    Run = seq_along(Distance),

    Distance = Distance,

    Velocity = V1,

    Expected_Velocity = V2,

    Time = T,

    Expected_Time = T2,

    bpm = bpm,

    Anaerobic_Threshold = SAN

  )

##Plots

par(mfrow=c(2,2))

plot(V1,main="Velocity(km / h)",xlab="Run",ylab="km / h",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(D1,main="Distance",xlab="Run",ylab="mt",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(T,main="Run time",xlab="Run",ylab="s",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(P1[,2] + P1[,1]*60,main="Run pace per km", xlab="Run",ylab="s",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)


par(mfrow=c(2,2))

plot(T2,main="Projection of times",xlab="Run",ylab="s",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(V2,main=paste0("expected velocity\n on reference distance of",D2," mt",sep=""),xlab="Run",ylab="km / h",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(P2[,2] + P2[,1]*60,main="Expected run pace per km (s)", xlab="Run", ylab="s",pch=16,type="o",lty=2)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)


par(mfrow=c(1,2))

plot(T, SAN,main="Anaerobic Threshold vs. Time",xlab="Time (s)",ylab="Anaerobic Threshold (km / h)",pch=16)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(SAN,main="Anaerobic Threshold",xlab="Run",ylab="Anaerobic Threshold (km / h)",pch=16)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)


plot(D1,V1,main="Velocity vs. Distance",xlab="Distance",ylab="Velocity (km / h)",pch=16)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)



par(mfrow=c(2,1))

plot(D1,FC,main="bpm vs. distance",ylab="bpm",xlab="distance (mt)",pch=16)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)

plot(V1,FC,main="bpm vs. velocity",xlab="velocity (km / h)",ylab="bpm",pch=16)

grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",lwd = par("lwd"), equilogs = TRUE)


return(DF)

}


This function evaluates the performance of running training sessions based on distance, time, and heart rate data. 

It calculates expected time, velocity, anaerobic threshold, and other metrics to provide insights into a runner's progress.



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