{"id":23110572,"url":"https://github.com/wanghui5801/tsdss","last_synced_at":"2025-10-08T08:18:18.807Z","repository":{"id":264044931,"uuid":"890152340","full_name":"wanghui5801/tsdss","owner":"wanghui5801","description":"Time series analysis tools.","archived":false,"fork":false,"pushed_at":"2024-11-21T17:41:55.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-13T12:17:53.232Z","etag":null,"topics":["filtering","nonlinear","signal-processing","surrogate","timeseries"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanghui5801.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-18T04:36:11.000Z","updated_at":"2024-11-21T17:45:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"34064295-f558-4c0c-a9a2-119f61b3d24a","html_url":"https://github.com/wanghui5801/tsdss","commit_stats":null,"previous_names":["wanghui5801/tsdss"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wanghui5801/tsdss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghui5801%2Ftsdss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghui5801%2Ftsdss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghui5801%2Ftsdss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghui5801%2Ftsdss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanghui5801","download_url":"https://codeload.github.com/wanghui5801/tsdss/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghui5801%2Ftsdss/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278910333,"owners_count":26067041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filtering","nonlinear","signal-processing","surrogate","timeseries"],"created_at":"2024-12-17T01:49:25.166Z","updated_at":"2025-10-08T08:18:18.775Z","avatar_url":"https://github.com/wanghui5801.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://ice.frostsky.com/2024/11/20/3b10b65c851c89af8ac5e11a72db1244.webp\" alt=\"TSDSS Logo\" width=\"200\"/\u003e\n\u003c/div\u003e\n\n# TSDSS 📊 🔮 📈\n\n[![PyPI version](https://badge.fury.io/py/tsdss.svg)](https://badge.fury.io/py/tsdss)\n[![Python](https://img.shields.io/pypi/pyversions/tsdss.svg)](https://pypi.org/project/tsdss/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Downloads](https://pepy.tech/badge/tsdss)](https://pepy.tech/project/tsdss)\n[![Build Status](https://github.com/wanghui5801/tsdss/workflows/Python%20Tests/badge.svg)](https://github.com/wanghui5801/tsdss/actions)\n\n\nTSDSS is a comprehensive Python package for time series analysis and surrogate data generation. It provides a wide range of tools for statistical analysis, preprocessing, feature extraction, and surrogate data generation for both univariate and multivariate time series.\n\n## Features\n\n### Time Series Analysis\n- Basic statistics (mean, std, skewness, kurtosis)\n- Stationarity tests (ADF test, Ljung-Box test)\n- Correlation analysis (Pearson, Spearman, Kendall)\n- Spectral analysis\n- Nonlinear analysis (Lyapunov exponent, phase space reconstruction)\n- Entropy measures\n\n### Time Series Preprocessing\n- Missing value interpolation\n- Outlier detection\n- Normalization\n- Resampling\n- Feature extraction\n\n### Surrogate Data Generation\n- IAAFT (Iterative Amplitude Adjusted Fourier Transform)\n- IAAFT+ (Enhanced IAAFT)\n- IPFT (Iterative Phase-adjusted Fourier Transform)\n- AIAAFT (Adaptive IAAFT)\n- IAAWT (Iterative Amplitude Adjusted Wavelet Transform)\n- Multivariate surrogate methods\n- Bootstrap methods\n\n### Time Series Filtering\n\nEach filter has its own characteristics and use cases:\n\n- **Moving Average Filter**: Simple and effective for reducing random noise\n- **Exponential Filter**: Gives more weight to recent data points\n- **Savitzky-Golay Filter**: Preserves higher moments of the data while smoothing\n- **Kalman Filter**: Optimal for tracking time-varying signals\n- **Butterworth Filter**: Frequency domain filtering with flat response\n- **Median Filter**: Excellent for removing impulse noise and outliers\n\nFor multivariate time series, the `multivariate_filter` function provides a unified interface to apply any of these filters to each dimension of the data. Key features:\n\n- Supports all single-variable filtering methods\n- Maintains correlations between dimensions\n- Handles errors gracefully for each dimension\n- Preserves the original data structure\n\n## Installation\n\n```bash\npip install tsdss\n```\n\n## Input Data Format\n\nTSDSS accepts the following input formats:\n- NumPy arrays (1D for univariate, 2D for multivariate)\n- Pandas Series (for univariate)\n- Pandas DataFrame (for multivariate)\n\nExample shapes:\n- Univariate: (n_samples,) or (n_samples, 1)\n- Multivariate: (n_samples, n_features)\n\n## Quick Start Examples\n\n### Basic Statistics and Analysis\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom tsdss  import ts_statistics, plot_decomposition, calculate_entropy\n\n# Basic time series statistics\nts = np.random.normal(0, 1, 1000)\nstats = ts_statistics(ts)\nprint(stats)\n\n# Plot time series decomposition\nplot_decomposition(ts)\n\n# Calculate entropy\nentropy = calculate_entropy(ts)\nprint(f\"Entropy: {entropy}\")\n```\n\n### Time Series Preprocessing\n\n```python\nfrom tsdss import interpolate_missing, detect_outliers, normalize_ts, resample_ts\n\n# Handle missing values\nts = pd.Series([1, np.nan, 3, np.nan, 5])\nts_clean = interpolate_missing(ts, method='linear')  # Options: linear, ffill, bfill, cubic, spline\n\n# Detect outliers\nts = np.random.normal(0, 1, 1000)\noutliers = detect_outliers(ts, method='zscore', threshold=3)  # Options: zscore, iqr, mad\n\n# Normalize data\nts_norm = normalize_ts(ts, method='zscore')  # Options: zscore, minmax, robust\n\n# Resample time series (requires datetime index)\ndates = pd.date_range('2023-01-01', periods=100, freq='D')\nts = pd.Series(np.random.randn(100), index=dates)\nts_resampled = resample_ts(ts, freq='W', method='mean')\n```\n\n### Feature Extraction\n\n```python\nfrom tsdss import extract_time_features, extract_freq_features\n\n# Extract time domain features\nts = np.random.normal(0, 1, 1000)\ntime_features = extract_time_features(ts)\nprint(\"Time domain features:\", time_features)\n\n# Extract frequency domain features\nfreq_features = extract_freq_features(ts)\nprint(\"Frequency domain features:\", freq_features)\n```\n\n### Correlation Analysis\n\n```python\nfrom tsdss import mutual_information, kendall_correlation\n\n# Calculate mutual information\nx = np.random.normal(0, 1, 1000)\ny = 0.5 * x + np.random.normal(0, 1, 1000)\nmi = mutual_information(x, y)\nprint(f\"Mutual Information: {mi}\")\n\n# Calculate Kendall correlation\nkendall = kendall_correlation(x, y)\nprint(f\"Kendall Correlation: {kendall}\")\n```\n\n### Surrogate Data Generation\n\n```python\nfrom tsdss  import (\n    iaaft, iaaft_plus, ipft, aiaaft, \n    multivariate_iaaft, block_bootstrap, \n    stationary_bootstrap\n)\n\n# Generate univariate surrogate data\nts = np.random.normal(0, 1, 1000)\n\n# IAAFT method\nsurrogate_iaaft = iaaft(ts, n_iterations=1000, num_surrogates=1)[0]\n\n# IAAFT+ method\nsurrogate_iaaft_plus = iaaft_plus(ts, n_iterations=1000, num_surrogates=1)[0]\n\n# IPFT method\nsurrogate_ipft = ipft(ts, n_iterations=1000, num_surrogates=1)[0]\n\n# Generate multivariate surrogate data\ndata = np.random.normal(0, 1, (1000, 3))  # 3-dimensional time series\nmv_surrogate = multivariate_iaaft(data, max_iter=100, num_surrogates=1)[0]\n\n# Bootstrap methods\nblock_samples = block_bootstrap(ts, block_length=50, num_bootstrap=100)\nstat_samples = stationary_bootstrap(ts, mean_block_length=50, num_bootstrap=100)\n```\n\n### Wavelet Analysis\n\n```python  \nfrom tsdss import dwt, idwt, iaawt\n\n# Perform discrete wavelet transform\nts = np.random.normal(0, 1, 1024)  # Length should be power of 2\ncoeffs = dwt(ts, level=3)\n\n# Perform inverse wavelet transform\nreconstructed = idwt(coeffs)\n\n# Generate wavelet-based surrogate\nsurrogate = iaawt(ts, n_iterations=1000, num_surrogates=1)[0]\n```\n\n### Advanced Multivariate Analysis\n\n```python\nfrom tsdss import (\n    mvts_surrogate_s_transform, \n    mvts_surrogate_wavelet,\n    mvts_surrogate_pca,\n    copula_surrogate\n)\n\n# Generate multivariate data\ndata = np.random.normal(0, 1, (1000, 5))\n\n# Different multivariate surrogate methods\nsurrogate_st = mvts_surrogate_s_transform(data, num_surrogates=1)[0]\nsurrogate_wavelet = mvts_surrogate_wavelet(data, num_surrogates=1)[0]\nsurrogate_pca = mvts_surrogate_pca(data, num_surrogates=1)[0]\nsurrogate_copula = copula_surrogate(data, num_surrogates=1)[0]\n```\n\n### Bootstrap Methods\n\n```python\nfrom tsdss import block_bootstrap, stationary_bootstrap\n\n# 1. Block Bootstrap\n# Fixed block length, suitable for data with strong local dependencies\nts = np.random.normal(0, 1, 1000)\nblock_samples = block_bootstrap(\n    data=ts, \n    block_length=50,  # Fixed block length\n    num_bootstrap=100\n)\n\n# 2. Stationary Bootstrap\n# Random block length (geometric distribution), preserves stationarity\nstat_samples = stationary_bootstrap(\n    data=ts, \n    mean_block_length=50,  # Average block length\n    num_bootstrap=100\n)\n\n# Compare the two methods\nprint(\"Block Bootstrap first sample:\", block_samples[0][:10])\nprint(\"Stationary Bootstrap first sample:\", stat_samples[0][:10])\n\n# Using with pandas Series\nts_series = pd.Series(ts)\nblock_samples_pd = block_bootstrap(ts_series, block_length=50, num_bootstrap=100)\nstat_samples_pd = stationary_bootstrap(ts_series, mean_block_length=50, num_bootstrap=100)\n\n# Key differences:\n# 1. Block Bootstrap: Uses fixed block length\n# 2. Stationary Bootstrap: Uses random block length (geometric distribution)\n#    - Better preserves stationarity\n#    - More suitable for time series with varying dependence structures\n```\n\n### Time Series Filtering\n\n```python\nfrom tsdss import (\n    moving_average_filter,\n    exponential_filter,\n    savitzky_golay_filter,\n    kalman_filter,\n    butterworth_filter,\n    median_filter,\n    multivariate_filter\n)\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n# 1. Univariate Filtering Example\nt = np.linspace(0, 10, 1000)\nnoisy_signal = np.sin(2*np.pi*0.5*t) + 0.5*np.random.normal(0, 1, 1000)\n\n# Apply different filters\nma_filtered = moving_average_filter(noisy_signal, window_size=5)\nema_filtered = exponential_filter(noisy_signal, alpha=0.3)\nsg_filtered = savitzky_golay_filter(noisy_signal, window_size=15, poly_order=3)\nkalman_filtered = kalman_filter(noisy_signal, Q=1e-5, R=1e-2)\n\n# 2. Multivariate Filtering Example\n# Generate sample multivariate data\nmv_data = np.column_stack([\n    np.sin(2*np.pi*0.5*t) + 0.5*np.random.normal(0, 1, 1000),\n    np.cos(2*np.pi*0.3*t) + 0.3*np.random.normal(0, 1, 1000),\n    0.5*t + np.random.normal(0, 0.2, 1000)\n])\n\n# Apply multivariate filter\nmv_filtered = multivariate_filter(\n    mv_data,\n    filter_type='kalman',\n    Q=1e-5,\n    R=1e-2\n)\n\n# You can also try different filter types\nmv_ma = multivariate_filter(mv_data, filter_type='ma', window_size=5)\nmv_butter = multivariate_filter(\n    mv_data, \n    filter_type='butter',\n    cutoff=0.1,\n    fs=100\n)\n```\n\n## Performance\n\nThe package uses optimized C++ implementations for core computations:\n- Trend decomposition\n- Skewness and kurtosis calculation\n- ACF computation\n- Ljung-Box test\n\n## Requirements\n\n- Python \u003e= 3.7\n- NumPy \u003e= 1.19.0\n- Pandas \u003e= 1.0.0\n- SciPy \u003e= 1.6.0\n- Statsmodels \u003e= 0.13.0\n- Scikit-learn \u003e= 0.24.0\n- Matplotlib \u003e= 3.0.0\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Version History\n\n### 0.2.0\n- Added comprehensive time series filtering functionality\n- Added multivariate filtering support\n- Improved documentation and examples\n- Bug fixes and performance improvements\n\n### 0.1.0\n- Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanghui5801%2Ftsdss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanghui5801%2Ftsdss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanghui5801%2Ftsdss/lists"}