-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathdistribution.py
46 lines (40 loc) · 1.44 KB
/
distribution.py
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
import numpy as np
class LaplaceDistribution:
@staticmethod
def mean_abs_deviation_from_median(x: np.ndarray):
'''
Args:
- x: A numpy array of shape (n_objects, n_features) containing the data
consisting of num_train samples each of dimension D.
'''
####
# Do not change the class outside of this block
# Your code here
####
def __init__(self, features):
'''
Args:
feature: A numpy array of shape (n_objects, n_features). Every column represents all available values for the selected feature.
'''
####
# Do not change the class outside of this block
self.loc = # YOUR CODE HERE
self.scale = # YOUR CODE HERE
####
def logpdf(self, values):
'''
Returns logarithm of probability density at every input value.
Args:
values: A numpy array of shape (n_objects, n_features). Every column represents all available values for the selected feature.
'''
####
# Do not change the class outside of this block
return
####
def pdf(self, values):
'''
Returns probability density at every input value.
Args:
values: A numpy array of shape (n_objects, n_features). Every column represents all available values for the selected feature.
'''
return np.exp(self.logpdf(value))