forked from DCBIA-OrthoLab/MFSDA_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat_kernel.py
More file actions
41 lines (28 loc) · 709 Bytes
/
stat_kernel.py
File metadata and controls
41 lines (28 loc) · 709 Bytes
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
"""
Construct kernel functions in MFSDA.
Author: Chao Huang (chaohuang.stat@gmail.com)
Last update: 2017-08-14
"""
import numpy as np
"""
installed all the libraries above
"""
def ep_kernel(x, h):
"""
Construct Epanechnikov kernel function in MFSDA.
Args:
x (matrix): vector or matrix in coordinate matrix
h (scalar): bandwidth
"""
x[np.absolute(x) > 1] = 1
ep_k = 0.75 * (1 - x**2) / h
return ep_k
def gau_kernel(x, h):
"""
Construct Gaussian kernel function in MFSDA.
Args:
x (matrix): vector or matrix in coordinate matrix
h (scalar): bandwidth
"""
gau_k = 1/np.sqrt(2*np.pi)*np.exp(-0.5*x**2)/h
return gau_k