Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AR Model Sample fails #23

Open
gibbs-hmm opened this issue Jul 7, 2023 · 0 comments
Open

AR Model Sample fails #23

gibbs-hmm opened this issue Jul 7, 2023 · 0 comments

Comments

@gibbs-hmm
Copy link

import timesynth as ts

Initializing TimeSampler

time_sampler = ts.TimeSampler(stop_time=20)

Sampling regular time samples

regular_time_samples = time_sampler.sample_regular_time(num_points=500)

Initializing AR(2) model
ar_p = ts.signals.AutoRegressive(ar_param=[1.5, -0.75])
ar_p_series = ts.TimeSeries(signal_generator=ar_p)
samples = ar_p_series.sample(regular_time_samples)

Fails with error
Traceback (most recent call last):
File "", line 1, in
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/timesynth/timeseries.py", line 63, in sample
signal = self.signal_generator.sample_next(t, samples[:i - 1], errors[:i - 1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/timesynth/signals/ar.py", line 54, in sample_next
ar_value = np.sum(ar_value) + noise
^^^^^^^^^^^^^^^^
File "<array_function internals>", line 200, in sum
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 2324, in sum
return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Running with Python 3.11.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant