-
-
Notifications
You must be signed in to change notification settings - Fork 399
/
index.d.ts
146 lines (128 loc) · 4.12 KB
/
index.d.ts
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* @license Apache-2.0
*
* Copyright (c) 2021 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// TypeScript Version: 2.0
/// <reference types="@stdlib/types"/>
import { NumericArray } from '@stdlib/types/array';
import { ndarray } from '@stdlib/types/ndarray';
/**
* Interface defining function options.
*/
interface Options {
/**
* Array of length two containing the bandwidth values for x and y.
*/
h?: NumericArray;
/**
* Number of partitions on the x- and y-axes (default: 25).
*/
n?: number;
/**
* Lower limit of x.
*/
xMin?: number;
/**
* Upper limit of x.
*/
xMax?: number;
/**
* Lower limit of y.
*/
yMin?: number;
/**
* Upper limit of y.
*/
yMax?: number;
/**
* A string or function to specifying the used kernel function (default: 'gaussian').
*/
kernel?: 'gaussian' | 'epanechnikov' | 'cosine' | 'quartic' | 'triangular' | 'tricube' | 'triweight' | 'uniform' | Function; // tslint-disable-line max-line-length
}
/**
* Density values for (x,y) gridpoints.
*/
interface Output {
/**
* x-values.
*/
x: Array<number>;
/**
* y-values.
*/
y: Array<number>;
/**
* Density values.
*/
z: Array<number>;
}
/**
* Computes two-dimensional kernel density estimates.
*
* @param arr - two column ndarray with the first column containing the `x` values and the second column containing the `y` values
* @param options - function options
* @param options.h - array of length two containing the bandwidth values for x and y
* @param options.n - number of partitions on the x- and y-axes (default: 25)
* @param options.xMin - lower limit of x
* @param options.xMax - upper limit of x
* @param options.yMin - lower limit of y
* @param options.yMax - upper limit of y
* @param options.kernel - a string or function to specifying the used kernel function (default: 'gaussian')
* @throws must provide valid options
* @returns object containing the density estimates (`z`) along grid points (`x` and `y` values)
*
* @example
* var ndarray = require( `@stdlib/ndarray/ctor` );
*
* var x = [ 0.6333, 0.8643, 1.0952, 1.3262, 1.5571, 1.7881, 2.019, 2.25, 2.481, 2.7119 ];
* var y = [ -0.0468, 0.8012, 1.6492, 2.4973, 3.3454, 4.1934, 5.0415, 5.8896, 6.7376, 7.5857 ];
*
* var buffer = x.concat( y );
* var n = x.length;
* var shape = [ n, 2 ];
* var strides = [ 1, n ];
* var offset = 0;
* var order = 'column-major';
*
* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );
* var out = kde2d( arr );
*/
declare function kde2d( arr: ndarray, options?: Options ): Output;
/**
* Computes two-dimensional kernel density estimates.
*
* @param x - array of x values
* @param y - array of y values
* @param options - function options
* @param options.h - array of length two containing the bandwidth values for x and y
* @param options.n - number of partitions on the x- and y-axes (default: 25)
* @param options.xMin - lower limit of x
* @param options.xMax - upper limit of x
* @param options.yMin - lower limit of y
* @param options.yMax - upper limit of y
* @param options.kernel - a string or function to specifying the used kernel function (default: 'gaussian')
* @throws first and second arguments must be of the same length
* @throws must provide valid options
* @returns object containing the density estimates (`z`) along grid points (`x` and `y` values)
*
* @example
* var x = [ 0.6333, 0.8643, 1.0952, 1.3262, 1.5571, 1.7881, 2.019, 2.25, 2.481, 2.7119 ];
* var y = [ -0.0468, 0.8012, 1.6492, 2.4973, 3.3454, 4.1934, 5.0415, 5.8896, 6.7376, 7.5857 ];
* var out = kde2d( x, y );
*/
declare function kde2d( x: NumericArray, y: NumericArray, options?: Options ): Output; // tslint-disable-line max-line-length
// EXPORTS //
export = kde2d;