Learn R Programming

seewave (version 1.4.5)

th: Temporal entropy

Description

Compute the entropy of a temporal envelope.

Usage

th(env)

Arguments

env
a data set resulting of an envelope obtained using oscillo with the argument env = TRUE.

Value

  • A single value varying between 0 and 1 is returned. The value has no unit.

Details

Temporal entropy is calculated according to: $$S = -\frac{\sum_{i = 1}^{N} y_i log_2(y_i)}{log_2(N)}$$ with: y = relative amplitude of the i envelope point, and $$\sum_{i = 1}^{N} y_i = 1$$ and N = number of envelope points.

See Also

sh, csh, H

Examples

Run this code
# Temporal entropy of a cicada song
data(orni)
envorni<-oscillo(orni,f=22050,env=TRUE,plot=FALSE)
th(envorni)
# [1] 0.8853535
# Smoothing the envelope might slightly change the result.
envorniS<-oscillo(orni,f=22050,env=TRUE,smooth=50,plot=FALSE)
th(envorniS)
# [1] 0.8515566
# If we mute a part of the cicada song, the temporal entropy decreases
orni2<-mute(orni,f=22050,from=0.3,to=0.55,plot=FALSE)
envorni2<-oscillo(orni2,f=22050,env=TRUE,plot=FALSE)
th(envorni2)
# [1] 0.837402
# The temporal entropy of noise tends towards 1
a<-noise(d=1,f=8000)
enva<-oscillo(a,f=8000,env=TRUE,plot=FALSE)
th(enva)
# [1] 0.9683144
# But be aware that the temporal entropy of a sustained sound also tends towards 1
b<-synth(f=8000,d=1,cf=2000,plot=FALSE)
envb<-oscillo(b,f=8000,env=TRUE,plot=FALSE)
th(envb)
# [1] 0.983882

Run the code above in your browser using DataLab