1
0
Fork 0
Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍 https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PyCTBN/main_package/classes/trajectory.py

40 lines
1.2 KiB

import numpy as np
class Trajectory:
"""
Rappresenta una traiettoria come un numpy_array contenente n-ple (indx, T_k,S_i,.....,Sj)
Offre i metodi utili alla computazione sulla struttura stessa.
Una Trajectory viene costruita a partire da una lista di numpyarray dove ogni elemento rappresenta una colonna
della traj
:actual_trajectory: il numpy_array contenente la successione di n-ple (indx, T_k,S_i,.....,Sj)
"""
def __init__(self, list_of_columns, original_cols_number):
if type(list_of_columns[0][0]) != np.float64:
raise TypeError('The first array in the list has to be Times')
#TODO valutare se vale la pena ordinare la lista di numpy array per tipo
self.original_cols_number = original_cols_number
self._actual_trajectory = np.array(list_of_columns[1:], dtype=np.int).T
self._times = np.array(list_of_columns[0], dtype=np.float)
@property
def trajectory(self):
return self._actual_trajectory[:, :self.original_cols_number]
@property
def complete_trajectory(self):
return self._actual_trajectory
@property
def times(self):
return self._times
def size(self):
return self.actual_trajectory.shape[0]