compmus_normalise.Rd
We use a number of vector normalisation strategies in Computational Musicology. This function brings them together into one place, along with common alternative names.
compmus_normalise(v, method = "euclidean")
compmus_normalize(v, method = "euclidean")
A numeric vector.
A character string indicating which normalization to use (see Details). Default is the Euclidean norm.
The following methods are supported.
identity
,id
No normalisation.
harmonic
Harmonic mean.
manhattan
,L1
Manhattan (L1) norm.
euclidean
,L2
Euclidean (L2) norm.
chebyshev
,maximum
Chebyshev (maximum) norm.
aitchison
,clr
Aitchison's clr transformation.
softmax
Softmax.
compmus_normalize
: Normalize vectors
library(tidyverse)
get_tidy_audio_analysis("6IQILcYkN2S2eSu5IHoPEH") %>%
select(segments) %>%
unnest(segments) %>%
mutate(pitches = map(pitches, compmus_normalise, "euclidean"))
#> # A tibble: 4,388 × 9
#> start duration confidence loudness_s…¹ loudn…² loudn…³ loudn…⁴ pitches timbre
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <list> <list>
#> 1 0 1.14 0 -60 0 -60 0 <dbl> <dbl>
#> 2 1.14 0.255 1 -60 0.00844 -35.5 0 <dbl> <dbl>
#> 3 1.40 0.337 1 -54.3 0.0432 -34.9 0 <dbl> <dbl>
#> 4 1.74 0.255 1 -53.7 0.00787 -33.9 0 <dbl> <dbl>
#> 5 1.99 0.291 1 -53.1 0.0436 -33.5 0 <dbl> <dbl>
#> 6 2.28 0.296 1 -54.0 0.0491 -34.1 0 <dbl> <dbl>
#> 7 2.58 0.296 1 -53.3 0.0493 -33.6 0 <dbl> <dbl>
#> 8 2.87 0.296 1 -53.5 0.0501 -34.3 0 <dbl> <dbl>
#> 9 3.17 0.296 1 -53.8 0.0471 -34.6 0 <dbl> <dbl>
#> 10 3.47 0.291 1 -54.0 0.0433 -34.2 0 <dbl> <dbl>
#> # … with 4,378 more rows, and abbreviated variable names ¹loudness_start,
#> # ²loudness_max_time, ³loudness_max, ⁴loudness_end