Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10,223 changes: 10,223 additions & 0 deletions rdas/AS.ipynb

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions rdas/AS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Callable
import numpy as np

def check_input(X):
# X : ndarray of input samples

assert len(X.shape) == 2 and type(X) == np.ndarray, 'X should be a 2d numpy array'
N, d = X.shape
return X, N, d

def get_n(S):
ediff = np.fabs(np.diff(S.reshape((S.size,))))
n = np.argmax(ediff)+1

return n

def compute_AS(X: np.ndarray, kde_pdf) -> np.ndarray:
# X : ndarray - input samples
# f_deriv : Callable - function derivative

X, N, d = check_input(X)

G = 1/np.sqrt(N) * np.column_stack([kde_pdf.grad(x) for x in X])
U, S, Vh = np.linalg.svd(G)

return get_n(S)
10,227 changes: 10,227 additions & 0 deletions rdas/Manifold.ipynb

Large diffs are not rendered by default.