This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from matplotlib.animation import FuncAnimation | |
| from matplotlib.patches import Ellipse | |
| import math | |
| # Kalman | |
| def lkf_predict(x, P, A, B, u, Q): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| o3d = np.array([-100, -100, 50]) | |
| d3d = np.array([1, 1, 5.]) | |
| d3d /= np.linalg.norm(d3d) | |
| t3d = np.arange(0, 100, 1.) | |
| p3d = o3d + d3d * t3d[:, None] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # Relation of SVD to PCA and eigen-problems | |
| # A = USV' | |
| # A'A = VSU'USV' = VS^2V' | |
| # A'AV = VS^2V'V | |
| # A'AV = VS^2 | |
| # which is an eigenvector problem. Means V are the eigenvectors of A'A. | |
| # A similar argument leads to U being the eigenvectors AA'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import json | |
| import pandas as pd | |
| import numpy as np | |
| def convert_to_pandas(content): | |
| events = [] | |
| for obj in content: | |
| for f in obj['frames']: | |
| events.append({ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from itertools import count | |
| def perm_matrix(perm_indices): | |
| '''Returns the permutation matrix corresponding to given permutation indices | |
| Here `perm_indices` defines the permutation order in the following sense: | |
| value `j` at index `i` will move row/column `j` of the original matrix to | |
| row/column `i`in the permuated matrix P*M/M*P^T. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Christoph Heindl' | |
| __copyright__ = 'Copyright 2017' | |
| __license__ = 'BSD' | |
| """Trains a HMM based on gradient descent optimization. | |
| The parameters (theta) of the model are transition and | |
| emission probabilities, as well as the initial state probabilities. | |
| Given a start solution, the negative log likelihood of data given the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scipy.optimize import linprog | |
| import numpy as np | |
| import pandas as pd | |
| def print_metrics(df): | |
| print('Total staff costs', df.to_numpy().sum()) | |
| print('Management cost ratio') | |
| print(df.MgtStaffCosts / df.to_numpy().sum()) | |
| print('Partner cost ratio') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| def sample_entropy( | |
| x: torch.Tensor, m: int = 2, r: float = None, stride: int = 1, subsample: int = 1 | |
| ): | |
| """Returns the (batched) sample entropy of the given time series. | |
| Sample entropy is a measure of complexity of sequences that can be related | |
| to predictability. Sample entropy (SE) is defined as the negative logarithm of | |
| the following ratio: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import dataclasses | |
| @dataclasses.dataclass | |
| class MotionEstimate: | |
| coeffs: np.ndarray # 3x1 | |
| t0: float | |
| degree: int = dataclasses.field(init=False) |
OlderNewer