PySDKit 0.3__py3-none-any.whl → 0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. PySDKit-0.4.dist-info/LICENSE +121 -0
  2. PySDKit-0.4.dist-info/METADATA +100 -0
  3. PySDKit-0.4.dist-info/RECORD +42 -0
  4. pysdkit/__init__.py +14 -5
  5. pysdkit/data/__init__.py +20 -10
  6. pysdkit/data/_add_noise.py +35 -0
  7. pysdkit/data/{generator.py → _generator.py} +240 -191
  8. pysdkit/emd/EMD.py +455 -454
  9. pysdkit/emd/__init__.py +2 -2
  10. pysdkit/emd/_find_extrema.py +137 -137
  11. pysdkit/emd/_prepare_points.py +270 -270
  12. pysdkit/{utils/splines.py → emd/_splines.py} +96 -96
  13. pysdkit/ewt/__init__.py +2 -0
  14. pysdkit/ewt/_ewt.py +449 -0
  15. pysdkit/metrics/_Index_of_Orthogonality.py +40 -0
  16. pysdkit/metrics/__init__.py +7 -0
  17. pysdkit/plot/__init__.py +2 -0
  18. pysdkit/plot/_fourier_spectra.py +134 -0
  19. pysdkit/plot/{functions.py → _functions.py} +102 -80
  20. pysdkit/plot/_plot_imfs.py +111 -0
  21. pysdkit/plot/main.py +4 -4
  22. pysdkit/utils/__init__.py +34 -17
  23. pysdkit/utils/_differ.py +28 -0
  24. pysdkit/utils/{fft.py → _fft.py} +22 -22
  25. pysdkit/utils/_function.py +58 -0
  26. pysdkit/utils/_smooth1d.py +93 -0
  27. pysdkit/utils/hilbert.py +104 -104
  28. pysdkit/utils/mirror.py +30 -24
  29. pysdkit/utils/process.py +142 -143
  30. pysdkit/vmd/__init__.py +4 -2
  31. pysdkit/vmd/_avmd.py +20 -0
  32. pysdkit/vmd/_mvmd.py +213 -0
  33. pysdkit/vmd/_svmd.py +21 -0
  34. pysdkit/vmd/{vmd_c.py → _vmd_c.py} +201 -172
  35. pysdkit/vmd/{vmd_f.py → _vmd_f.py} +138 -138
  36. pysdkit/vmd/base.py +70 -0
  37. pysdkit/vncmd/__init__.py +1 -0
  38. pysdkit/vncmd/vncmd.py +284 -0
  39. PySDKit-0.3.dist-info/METADATA +0 -27
  40. PySDKit-0.3.dist-info/RECORD +0 -30
  41. pysdkit/mvmd/__init__.py +0 -0
  42. pysdkit/plot/imf.py +0 -6
  43. pysdkit/utils/base.py +0 -45
  44. {PySDKit-0.3.dist-info → PySDKit-0.4.dist-info}/WHEEL +0 -0
  45. {PySDKit-0.3.dist-info → PySDKit-0.4.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.1
2
+ Name: PySDKit
3
+ Version: 0.4
4
+ Summary: A Python library for signal decomposition algorithms with a unified interface
5
+ Home-page: https://github.com/wwhenxuan/PySDKit
6
+ Author: whenxuan
7
+ Author-email: wwhenxuan@gmail.com
8
+ Keywords: signal,decomposition
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.6
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Requires-Python: >=3.6
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy (>=1.24.3)
24
+ Requires-Dist: scipy (>=1.11.1)
25
+ Requires-Dist: matplotlib (>=3.7.2)
26
+
27
+ # PySDKit: signal decomposition in Python
28
+
29
+ [![PyPI version](https://badge.fury.io/py/PySDKit.svg)](https://pypi.org/project/PySDKit/) ![License](https://img.shields.io/github/license/wwhenxuan/PySDKit) [![codecov](https://codecov.io/gh/wwhenxuan/PySDKit/branch/main/graph/badge.svg?token=YOUR_TOKEN)](https://codecov.io/gh/wwhenxuan/PySDKit) [![arXiv](https://img.shields.io/badge/arXiv-1234.56789-brightgreen.svg)](https://arxiv.org/abs/1234.56789) [![Downloads](https://pepy.tech/badge/pysdkit)](https://pepy.tech/project/pysdkit) ![Static Badge](https://img.shields.io/badge/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fjust%2520the%2520message--8A2BE2?logo=appveyor&logoColor=royalblue&label=NumPy&link=https%3A%2F%2Fnumpy.org%2Fdoc%2Fstable%2F) ![Static Badge](https://img.shields.io/badge/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fjust%2520the%2520message--8A2BE2?logo=appveyor&logoColor=violet&label=SciPy&link=https%3A%2F%2Fdocs.scipy.org%2Fdoc%2Fscipy%2F)
30
+
31
+
32
+ A Python library for signal decomposition algorithms
33
+
34
+ <div align="center">
35
+ <img src=".\images\Logo_sd.png" alt="Logo_sd" width="500"/>
36
+ </div>
37
+
38
+ ## Installation
39
+
40
+ You can install `PySDKit` through pip.
41
+
42
+ ~~~
43
+ pip install pysdkit
44
+ ~~~
45
+
46
+ We only used [`NumPy`](https://numpy.org/), [`Scipy`](https://scipy.org/) and [`matplotlib`](https://matplotlib.org/) when developing the project.
47
+
48
+ ## Example script
49
+
50
+ This project integrates simple signal processing methods, signal decomposition and visualization, and builds a general interface similar to [`Scikit-learn`](https://scikit-learn.org/stable/). It is mainly divided into three steps:
51
+ 1. Import the signal decomposition method;
52
+ 2. Create an instance for signal decomposition;
53
+ 3. Use the `fit_transform` method to implement signal decomposition;
54
+ 4. Visualize and analyze the original signal and the intrinsic mode functions IMFs obtained by decomposition.
55
+
56
+ ~~~python
57
+ from pysdkit import EMD
58
+ from pysdkit.data import test_emd
59
+ from pysdkit.plot import plot_IMFs
60
+
61
+ t, signal = test_emd()
62
+
63
+ # create an instance for signal decomposition
64
+ emd = EMD()
65
+ # implement signal decomposition
66
+ IMFs = emd.fit_transform(signal, max_imf=2)
67
+ plot_IMFs(signal, IMFs)
68
+ ~~~
69
+
70
+ <img src=".\images\example.jpg" alt="example" />
71
+
72
+ The EMD in the above example is the most classic `empirical mode decomposition` algorithm in signal decomposition. For more complex signals, you can try other algorithms such as variational mode decomposition ([`VMD`](https://ieeexplore.ieee.org/abstract/document/6655981)).
73
+
74
+ ~~~python
75
+ from pysdkit import VMD
76
+
77
+ # load new signal
78
+ signal = np.load("example.npy")
79
+
80
+ # use variational mode decomposition
81
+ vmd = VMD(alpha=500, K=3, tau=0.0, tol=1e-9)
82
+ IMFs = vmd.fit_transform(signal=signal)
83
+ print(IMFs.shape)
84
+
85
+ vmd.plot_IMFs(save_figure=True)
86
+ ~~~
87
+
88
+ <img src=".\images\vmd_example.jpg" alt="vmd_example.jpg" />
89
+
90
+ Better observe the characteristics of the decomposed intrinsic mode function in the frequency domain.
91
+
92
+ ~~~python
93
+ from pysdkit.plot import plot_IMFs_amplitude_spectra
94
+
95
+ # frequency domain visualization
96
+ plot_IMFs_amplitude_spectra(IMFs, smooth="exp") # use exp smooth
97
+ ~~~
98
+
99
+ <img src=".\images\frequency_example.jpg" alt="frequency_example" />
100
+
@@ -0,0 +1,42 @@
1
+ pysdkit/__init__.py,sha256=nsuYXOdFNc3J-NNu5kkMXbeF8z_CBVLIo3tTKwEP53k,259
2
+ pysdkit/data/__init__.py,sha256=i_ZMKR_FcLq8wWXJ0MyLA4S41iXTMWbpf9sGpoLWdpw,621
3
+ pysdkit/data/_add_noise.py,sha256=8cGzAquIPlf0hzTMUOBj8R1SEjGd2-JveWyzPPII05M,949
4
+ pysdkit/data/_generator.py,sha256=gW7D9A8OTKJ5CBQ40oTbowu9PMZx-WiyN43oz42OAL4,12119
5
+ pysdkit/emd/BEMD.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pysdkit/emd/EMD.py,sha256=xyQT7IqitAQ9mdOfDDh4QEwlFU7SODl_9y5wd3M-v-k,18090
7
+ pysdkit/emd/__init__.py,sha256=HdOfha6kuiKz2sdTENF_7bHTN2BT2Qtr5i1xXc9dOm8,22
8
+ pysdkit/emd/_find_extrema.py,sha256=EnUZB9Z4uUaVTfuH2J2hERUR6cmsWQ890gQt8BpE1f0,5368
9
+ pysdkit/emd/_prepare_points.py,sha256=XwEkwRPmHTZZcHhjiBx2lv_Qvj-gx2lw76locyOBf-8,10528
10
+ pysdkit/emd/_splines.py,sha256=aaAULcznyn6mSciDeht4hdKZx1MhvKTvd0Z-bQVpd9E,2575
11
+ pysdkit/emd2d/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ pysdkit/ewt/__init__.py,sha256=Yz5QcfLHTqf_69qJ663ESoUzrbKSnhHY0angsegqhvk,60
13
+ pysdkit/ewt/_ewt.py,sha256=TVo7GbVtBtFr7vHFQmE2PPyxX3hp0Pe3aNQyNAH_P5E,15703
14
+ pysdkit/metrics/_Index_of_Orthogonality.py,sha256=nmUEP56TVeZqKogP0QqylJwLL3QMxUNLup273PM1yV4,1128
15
+ pysdkit/metrics/__init__.py,sha256=4TgRjJuOxNMCEloP-Vnq-z5VnrzYKQCypUaAMJb_nkI,169
16
+ pysdkit/plot/__init__.py,sha256=_SklnKYnFm42Yso9R_UGkzwyyi98tTngkHhgQ4JrIug,92
17
+ pysdkit/plot/_fourier_spectra.py,sha256=7HzjHf6EeZ2DScgvMvveIQYSPVhXLfQSL6sGSUJmGZc,5068
18
+ pysdkit/plot/_functions.py,sha256=rakosRbEg6KgdQJB26x6DGO6On3Ht9KD2MR2Wu7gSyc,4040
19
+ pysdkit/plot/_plot_imfs.py,sha256=YsVyazrSwBzQ3EmLj7pzZqVmxolTbSljYnAP-sIJRdQ,4239
20
+ pysdkit/plot/main.py,sha256=O_CKGAPPVaNBOqZwA7FrWcGJJEz76bbL_PomNJMtO7w,102
21
+ pysdkit/utils/__init__.py,sha256=6M-DhV8ghK_O2PoMBnj6tLbv_3XcR1CeAqxw-DM0Ass,1076
22
+ pysdkit/utils/_differ.py,sha256=q0AoYecFLOlPsFcbjV7G_r4AGfp8WfVJ3aD9rbHIdJo,866
23
+ pysdkit/utils/_fft.py,sha256=VgluJaLeuuJ333_kJH1CKDbnlc6m_KX60pNfdRbv73Q,472
24
+ pysdkit/utils/_function.py,sha256=dBF4gSjEBavAZjx0PrnZ8Z_iBk5T-zLmU3XEC1XvwTE,1436
25
+ pysdkit/utils/_smooth1d.py,sha256=ICovGCD53Wb0YX2b0eOPEsrK85RNccbbb_zA_Wu4_Bw,3485
26
+ pysdkit/utils/hilbert.py,sha256=74DLvAmfWOdhS391RoRBAzJ-P6rnldaPLYc3xexNPWI,3793
27
+ pysdkit/utils/mirror.py,sha256=I4mV_pskDQjuPxLfq20jIOY0MRHI1doZd3wxvaxQhTI,1195
28
+ pysdkit/utils/process.py,sha256=mtlY6ftqwdtjXVLVxvczUb0_ug41jZa5k__29hUR1cc,6149
29
+ pysdkit/vmd/__init__.py,sha256=nNmNpo65_SlqZhqQXsYj-FRkCO-KHSRY2XeGp5vmzPo,73
30
+ pysdkit/vmd/_avmd.py,sha256=xUtmiyFOqkol7Oqh_yDPzGAr6b7FrfVXG6AlDOnTvr8,473
31
+ pysdkit/vmd/_mvmd.py,sha256=ANXqmfJA0Y5Ib80Yw0URzqHIIFFiJfg5p1CswTXiM1o,9109
32
+ pysdkit/vmd/_svmd.py,sha256=JDoR0BrocbsHn-zeg2fJ4wkuykEVh700yZKdgPk5M2o,384
33
+ pysdkit/vmd/_vmd_c.py,sha256=BxgdERwbyEE88NWvaKCuhSBxB3gz9hUr-2qWDoRpfZU,8758
34
+ pysdkit/vmd/_vmd_f.py,sha256=kb2GiAThe_xqU7qLATkOdlbXj4kWFFLayKJ1nouc6eQ,5402
35
+ pysdkit/vmd/base.py,sha256=frcDhMadR2WHM6UTnjGgufAiZhweqrNti9E71h7zUQI,3442
36
+ pysdkit/vncmd/__init__.py,sha256=n9grWZ12fpbtfAtiQO50Bkg1sB0eiUDXbiMmbWk_i8c,25
37
+ pysdkit/vncmd/vncmd.py,sha256=digpTAUGRsddbS3bM-9p6-5tENq-__AT7aonYgVHEzA,12362
38
+ PySDKit-0.4.dist-info/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
39
+ PySDKit-0.4.dist-info/METADATA,sha256=of4rNNif_JkVzmWHNyit6nXJjnqvKGTV4anDdQ9HOFw,4268
40
+ PySDKit-0.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
41
+ PySDKit-0.4.dist-info/top_level.txt,sha256=wN_Yil0woB5Tu_WrIRt4_T4eoRyXljCYvH0dL6-7ei0,8
42
+ PySDKit-0.4.dist-info/RECORD,,
pysdkit/__init__.py CHANGED
@@ -1,5 +1,14 @@
1
- # 经验模态分解算法
2
- from .emd import EMD
3
-
4
- # 变分模态分解算法
5
- from .vmd import vmd, VMD
1
+ # 经验模态分解算法
2
+ from .emd import EMD
3
+
4
+ # 变分模态分解算法
5
+ from .vmd import vmd, VMD
6
+
7
+ # 多元变分模态分解算法
8
+ from .vmd import MVMD
9
+
10
+ # 非线性啁啾模式分解
11
+ from .vncmd import VNCMD
12
+
13
+ # 经验小波变换
14
+ from .ewt import EWT1D
pysdkit/data/__init__.py CHANGED
@@ -1,10 +1,20 @@
1
- # A series of functions for generating 1D NumPy signals
2
- from .generator import generate_sin_signal, generate_cos_signal
3
- from .generator import generate_square_wave, generate_triangle_wave, generate_sawtooth_wave
4
- from .generator import generate_am_signal, generate_exponential_signal
5
-
6
- # Generates the main test sample signal
7
- from .generator import test_emd
8
-
9
- # Functions that generate signal visualizations
10
- from .generator import plot_generate_signal
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on 2024/7/22 22:56
4
+ @author: Whenxuan Wang
5
+ @email: wwhenxuan@gmail.com
6
+ """
7
+
8
+ # A series of functions for generating 1D NumPy signals
9
+ from ._generator import generate_sin_signal, generate_cos_signal
10
+ from ._generator import generate_square_wave, generate_triangle_wave, generate_sawtooth_wave
11
+ from ._generator import generate_am_signal, generate_exponential_signal
12
+
13
+ # Generates the main test sample signal
14
+ from ._generator import test_emd
15
+
16
+ # Functions that generate signal visualizations
17
+ from ._generator import plot_generate_signal
18
+
19
+ # add Gaussian noise
20
+ from ._add_noise import add_noise
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Sat Mar 8 21:45:02 2024
4
+ @author: Whenxuan Wang
5
+ @email: wwhenxuan@gmail.com
6
+ """
7
+ import numpy as np
8
+
9
+
10
+ def add_noise(N: int, Mean: float, STD: float) -> np.ndarray:
11
+ """
12
+ Generate Gaussian white noise with mean values Mean and standard deviation STD.
13
+ :param N: The number of samples.
14
+ :param Mean: The mean value of the noise.
15
+ :param STD: The standard deviation of the noise.
16
+ :return: numpy.ndarray: Generated Gaussian white noise.
17
+ """
18
+ # Generate noise using the given mean and standard deviation
19
+ y = np.random.randn(N)
20
+ # Standardize y so that its standard deviation is 1
21
+ y = y / np.std(y)
22
+ # Adjust y so that its mean is 0
23
+ y = y - np.mean(y)
24
+ # Generate noise using the given mean and standard deviation
25
+ y = Mean + STD * y
26
+
27
+ return y
28
+
29
+
30
+ if __name__ == '__main__':
31
+ N = 1000
32
+ Mean = 0
33
+ STD = 1
34
+ noise = add_noise(N, Mean, STD)
35
+ print(noise)