## 3 Implementation
### Encoding and Decoding Strategies for Data Normalization and Retrotranscription
#### 3.3.4 Genotype Function Indices  
Encoded genotypes must refer unequivocally to the available functions \(\in E_{func}\) contained in any functional tree. So, as a first requirement, any genotype function must be pointed by a unique index \(\in V\). All functions keep their indices unchanged, to ensure that an encoded genotype will always be decoded as the same functional expression, regardless of changes in set \(Funcs\) after adding new functions to the library. At the same time, these indices must be as separated and uniformly distributed as possible in the interval \([0,1]\) to obtain distinct vectors that are easily distinguishable for machine learning algorithms. Finally, we must assign indices to new genotype functions without knowing how many new ones will be added in the future.  
To deal with all these requirements, a special conversion has been implemented. We call this the _golden encoded value_ (or simply the golden value) to a float \(\in V\) obtained after applying a bijective map based on the well-known properties of the golden angle (an angular version of the golden section), combined with modular arithmetics.  
Taking \(\varphi=\frac{1}{2}(1+\sqrt{5})\) as the golden ratio and \(r\) as a function, and reducing to \(6\) digits the mantissa of a real number, the function  
\[g(n)=r(n\varphi\mod 1)\mid n\in\mathbb{N}_{>0},n<max_{n}, \tag{12}\]  
where mod is a modulus operator that works with floating-point numbers, and \(max_{n}\), the first integer producing a repeated value, returns the golden value corresponding to the  
Figure 3: Conversion of normalized values \(\in[0,1]\) to human-readable \(midpitch\) values \(\in[0,127]\).  
integer \(n\). The limited quantity \(max_{n}\) of integers able to generate unique values \(g(n)\) until reaching a repeated golden value is \(>\)10\({}^{5}\), so that there are far more different indices than are needed.  
This conversion has a very convenient feature: despite ignoring how many values will be needed to be stored, the distribution across the interval \([0,1]\) is stochastically well balanced. Figure 4 shows how the distribution of indices uniformly covers the range of normalized values. This kind of mapping based on the modulation of golden-angle properties to obtain the balanced distributions of an unknown quantity of indices is not common, although some methods have been recently proposed [32] to obtain simple algorithms to deal with similar optimization problems in other domains.  
Once this bijection is defined, each new genotype function is assigned an integer index converted to its reciprocal encoded golden value. The transformation _tran_ then takes each number in a germinal vector that represents a call for a genotype function and substitutes it with the closest available index of the output type required by its parent function, as illustrated in Figure 5.  
Golden values are also useful for encoding integers in other contexts, both in genotypes and phenotypes, as shown in Figures 6 and 7. Some genotype functions accept integers without a defined range as arguments, which involve this map again. For phenotype encoding, golden values are indispensable for specifying discrete features such as the number of voices per score, events per voice, and items inside a multiparameter.  
Figure 4: First 125 golden encoded values across interval \([0,1]\). Every value is projected horizontally to visualize the balanced accumulative distribution.  
Figure 5: For this example, we assume that only genotype functions with the decoded indices 1, 2, 3, and 4 are eligible for a given output type. Consequently, the value provided by the germinal vector is substituted by its closest number among the available golden values \(g(1)\), \(g(2)\), \(g(3)\), and \(g(4)\); 0.372 is replaced by \(g(4)=0.472136\), a permanent pointer to a function. This transformation ensures the rendering of the exact same specimen, regardless of working with an extended function library in the future.