-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMahalanobis_testdata.js
More file actions
59 lines (41 loc) · 2.08 KB
/
Copy pathMahalanobis_testdata.js
File metadata and controls
59 lines (41 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Example data: for Mahalanobis1.js and Mahalanobis2.js
// Load data (from JSON on GitHub) for prototyping:
// Uncomment url to begin...
// let url = "https://raw.githubusercontent.com/coreydevinanderson/ESDA.js/main/test.json";
let xhReq = new XMLHttpRequest();
xhReq.open("GET", url, false);
xhReq.send(null);
let jsonObject = JSON.parse(xhReq.responseText);
// console.log(Object.keys(jsonObject))
// ["County_FIPS","County","State","EPL_AGE65","EPL_POV","EPL_MINRTY","EPL_NOHSDP","EPL_UNEMP","Diabetes_pct"]
// Save indicators as separate variables for protoyping:
let EPL_AGE65 = jsonObject.EPL_AGE65;
let EPL_POV = jsonObject.EPL_POV;
let EPL_MINRTY = jsonObject.EPL_MINRTY;
let EPL_NOHSDP = jsonObject.EPL_NOHSDP;
let EPL_UNEMP = jsonObject.EPL_UNEMP;
let Diabetes_pctr = jsonObject.Diabetes_pct;
let EPL_AGE65_10 = EPL_AGE65.slice(0, 10);
let EPL_POV_10 = EPL_POV.slice(0, 10);
let EPL_MINRTY_10 = EPL_MINRTY.slice(0, 10);
let EPL_NOHSDP_10 = EPL_NOHSDP.slice(0, 10);
let EPL_UNEMP_10 = EPL_UNEMP.slice(0, 10);
let Diabetes_pctr_10 = Diabetes_pctr.slice(0, 10);
let testMatrix_10 = [EPL_AGE65_10, EPL_POV_10, EPL_MINRTY_10, EPL_NOHSDP_10, EPL_UNEMP_10, Diabetes_pctr_10];
//------------------------------------------------------------------------------
// Example data:
// Data are percentile ranks for five indicators from SVI 2018 and diabetes:
const FIPS_01001 = [0.1850, 0.5401, 0.6336, 0.4397, 0.2745, 0.7074];
const FIPS_01003 = [0.6428, 0.2239, 0.5158, 0.3209, 0.3121, 0.4925];
const FIPS_01005 = [0.4893, 0.9631, 0.8965, 0.9701, 0.9217, 0.9799];
// with nulls
const FIPS_01001x = [0.1850, null, 0.6336, 0.4397, 0.2745, 0.7074];
const FIPS_01003x = [0.6428, 0.2239, 0.5158, null, 0.3121, 0.4925];
// console.log(distEuclidean(FIPS_01001, FIPS_01003))
// console.log(distEuclidean2(FIPS_01001x, FIPS_01003x))
// console.log(subtractVectors(FIPS_01001, FIPS_01003))
// console.log(subtractVectors(FIPS_01001x, FIPS_01003))
let testMatrix = [FIPS_01001, FIPS_01003, FIPS_01005];
let testMatrixX = [FIPS_01001x, FIPS_01003x, FIPS_01005];
// console.log(testMatrix);
// console.log(testMatrixX);