compmus_normalise.RdWe 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,idNo normalisation.
harmonicHarmonic mean.
manhattan,L1Manhattan (L1) norm.
euclidean,L2Euclidean (L2) norm.
chebyshev,maximumChebyshev (maximum) norm.
aitchison,clrAitchison's clr transformation.
softmaxSoftmax.
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