Skip to content

Commit

Permalink
Normalizer: implement simple derivative to remove scipy dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Jan 6, 2025
1 parent 5dc6b16 commit 64b102e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gstools/normalizer/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
import warnings

import numpy as np
import scipy.misc as spm
import scipy.optimize as spo


def _derivative(f, x, dx=1e-6):
"""Central difference formula."""
return (f(x + dx) - f(x - dx)) / (2 * dx)


class Normalizer:
"""Normalizer class.
Expand Down Expand Up @@ -57,7 +61,7 @@ def _normalize(self, data):
return data

def _derivative(self, data):
return spm.derivative(self._normalize, data, dx=self._dx)
return _derivative(self._normalize, data, dx=self._dx)

def _loglikelihood(self, data):
add = -0.5 * np.size(data) * (np.log(2 * np.pi) + 1)
Expand Down

0 comments on commit 64b102e

Please sign in to comment.