view LazyBear/Functions/Normalize.swift @ 180:0df6396f7e28

Test charts
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sun, 21 Feb 2021 17:38:49 +0100
parents 235ee168a9c3
children
line wrap: on
line source

//
//  Normalize.swift
//  LazyBear
//
//  Created by Dennis Concepción Martín on 20/2/21.
//

import Foundation

func normalize(_ data: [Double]) -> [Double] {
    var normalData = [Double]()
    let min = data.min()!
    let max = data.max()!
    
    for value in data {
        let normal = (value - min) / (max - min)
        normalData.append(normal)
    }
    
    return normalData
}