@@ -48,11 +48,9 @@ class _BaseSINDy(BaseEstimator, ABC):
4848
4949 feature_library : BaseFeatureLibrary
5050 optimizer : _BaseOptimizer
51- discrete_time : bool
5251 model : Pipeline
5352 # Hacks to remove later
5453 feature_names : Optional [list [str ]]
55- discrete_time : bool = False
5654 n_control_features_ : int = 0
5755
5856 @abstractmethod
@@ -83,9 +81,7 @@ def _fit_shape(self):
8381
8482 def predict (self , x , u = None ):
8583 """
86- Predict the time derivatives if it is a SINDy model.
87- Predict the next state of the system if it is a DiscreteSINDy model.
88-
84+ Predict the right hand side of the dynamical system
8985
9086 Parameters
9187 ----------
@@ -100,8 +96,8 @@ def predict(self, x, u=None):
10096
10197 Returns
10298 -------
103- x_next : array-like or list of array-like, shape (n_samples, n_input_features)
104- Predicted next state of the system
99+ result : array-like or list of array-like, shape (n_samples, n_input_features)
100+ Predicted right hand side of the dynamical system
105101 """
106102 if not _check_multiple_trajectories (x , None , u ):
107103 x , _ , _ , u = _adapt_to_multiple_trajectories (x , None , None , u )
@@ -227,25 +223,25 @@ class SINDy(_BaseSINDy):
227223
228224 Parameters
229225 ----------
230- optimizer : optimizer object, optional
226+ optimizer
231227 Optimization method used to fit the SINDy model. This must be a class
232228 extending :class:`pysindy.optimizers.BaseOptimizer`.
233- The default is :class:`STLSQ`.
229+ The default is :class:`pysindy.optimizers. STLSQ`.
234230
235- feature_library : feature library object, optional
231+ feature_library
236232 Feature library object used to specify candidate right-hand side features.
237233 This must be a class extending
238234 :class:`pysindy.feature_library.base.BaseFeatureLibrary`.
239- The default option is :class:`PolynomialLibrary`.
235+ The default option is :class:`pysindy.feature_library. PolynomialLibrary`.
240236
241- differentiation_method : differentiation object, optional
237+ differentiation_method
242238 Method for differentiating the data. This must be a class extending
243- :class:`pysindy.differentiation_methods .base.BaseDifferentiation` class.
239+ :class:`pysindy.differentiation .base.BaseDifferentiation` class.
244240 The default option is centered difference.
245241
246242 Attributes
247243 ----------
248- model : ``sklearn.multioutput.MultiOutputRegressor`` object
244+ model : ``sklearn.multioutput.MultiOutputRegressor``
249245 The fitted SINDy model.
250246
251247 n_input_features_ : int
@@ -745,6 +741,45 @@ class DiscreteSINDy(_BaseSINDy):
745741 [0.79648209],
746742 [0.58382694],
747743 [0.87479097]])
744+
745+ >>> import numpy as np
746+ >>> num = 1000
747+ >>> N = 1000
748+ >>> N_drop = 500
749+ >>> r0 = 3.5
750+ >>> rs = r0 + np.arange(num) / num * (4 - r0)
751+ >>> xss = []
752+ >>> for r in rs:
753+ >>> xs = []
754+ >>> x = 0.5
755+ >>> for n in range(N + N_drop):
756+ >>> if n >= N_drop:
757+ >>> xs = xs + [x]
758+ >>> x = r * x * (1 - x)
759+ >>> xss = xss + [xs]
760+ .. plot::
761+ >>> import matplotlib.pyplot as plt
762+ >>> plt.figure(figsize=(4, 4), dpi=100)
763+ >>> for r, xs in zip(r_values, xss):
764+ >>> plt.plot([r]*len(xs), xs, ",", alpha=0.1, c="black", rasterized=True)
765+ >>> plt.xlabel("$r$")
766+ >>> plt.ylabel("$x_n$")
767+ >>> plt.show()
768+ >>> rs_train = [3.6, 3.7, 3.8, 3.9]
769+ >>> xs_train = [np.array(xss[np.where(np.array(rs) == r)[0][0]]) for r in rs_train]
770+ >>> feature_lib = ps.PolynomialLibrary(degree=3, include_bias=True)
771+ >>> parameter_lib = ps.PolynomialLibrary(degree=1, include_bias=True)
772+ >>> lib = ps.ParameterizedLibrary(
773+ >>> feature_library=feature_lib,
774+ >>> parameter_library=parameter_lib,
775+ >>> num_features=1,
776+ >>> num_parameters=1,
777+ >>> )
778+ >>> opt = ps.STLSQ(threshold=1e-1, normalize_columns=False)
779+ >>> model = ps.DiscreteSINDy(feature_library=lib, optimizer=opt)
780+ >>> model.fit(xs_train, u=rs_train, t=1, feature_names=["x", "r"])
781+ >>> model.print()
782+ (x)[k+1] = 1.000 r[k] x[k] + -1.000 r[k] x[k]^2
748783 """
749784
750785 def __init__ (
0 commit comments