opensmfs / pycorrelate Goto Github PK
View Code? Open in Web Editor NEWThis project forked from tritemio/pycorrelate
Fast and accurate cross-correlation over arbitrary time lags.
Home Page: https://pycorrelate.readthedocs.io
License: Other
This project forked from tritemio/pycorrelate
Fast and accurate cross-correlation over arbitrary time lags.
Home Page: https://pycorrelate.readthedocs.io
License: Other
I was trying the examples from documentation from the below URL.
https://pycorrelate.readthedocs.io/en/latest/notebooks/pycorrelate-examples.html#Log-scale-bins-(base-10)
I aplogize for being naive here.
How do I interpret the value G? How does it says that "t" and "u" correlated?
Can I get G value between 0 and 1, I mean if value near to 1 then 't' and 'u' highly correlated.
When you want to use the correlation algorithms with pythonic lists instead of numpy arrays, the program crashes badly. This could easily be fixed with a check on whether the function arguments are lists, and calling np.array()
in that case.
from pycorrelate import pcorrelate
X = [1,2]
Y = [3,4]
edges = [1,2,3,4]
pcorrelate(X, Y, edges)
The resulting crash is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\dispatcher.py", line 401, in _compile_for_args
error_rewrite(e, 'typing')
File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\dispatcher.py", line 344, in error_rewrite
reraise(type(e), e, None)
File "C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\numba\six.py", line 668, in reraise
raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
�[1m�[1m�[1mInvalid use of Function(<function diff at 0x000001AD75F4C488>) with argument(s) of type(s): (reflected list(int64))
* parameterized
�[1mIn definition 0:�[0m
�[1m All templates rejected with literals.�[0m
�[1mIn definition 1:�[0m
�[1m All templates rejected without literals.�[0m
�[1mThis error is usually caused by passing an argument of a type that is unsupported by the named function.�[0m�[0m
�[0m�[1m[1] During: resolving callee type: Function(<function diff at 0x000001AD75F4C488>)�[0m
�[0m�[1m[2] During: typing of call at C:\Users\meassi\AppData\Local\Programs\Python\Python36\lib\site-packages\pycorrelate\pycorrelate.py (111)
�[0m
�[1m
File "..\..\..\..\AppData\Local\Programs\Python\Python36\lib\site-packages\pycorrelate\pycorrelate.py", line 111:�[0m
�[1mdef pcorrelate(t, u, bins, normalize=False):
<source elided>
counts += imax - imin
�[1m G = counts / np.diff(bins)
�[0m �[1m^�[0m�[0m
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.
To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html
For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile
If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
The documentation for ucorrelate says the following: "The classical text-book linear cross-correlation between two signals defined at uniformly spaced intervals." I know that it is fairly obvious, but it would nevertheless be good to restate as follows: "The classical textbook linear cross-correlation between two signals defined at uniformly-spaced intervals with the same interval size."
Issue moved from https://github.com/tritemio/pycorrelate/issues/7. Original author @Phillip-M-Feldman.
I wrote a script to compare the runtime perforance of numpy.correlate
and pycorrelate.ucorrelate
. The input sequences have length 1e5, and the maximum lag of interest is 10,000. Since I can't specify a maximum lag with numpy.correlate
, I used the mode='same'
option.
Although numpy.correlate
does the full cross-correlation, and was thus expected to be much slower, the results showed that it is actually faster (the following test results are based on 10 iterations in each case):
elapsed (wall time) | user CPU | system CPU
numpy: 37.03 | 141.09 | 6.92
pycorrelate: 106.91 | 55.62 | 51.78
I'm wondering if you have any thoughts re. why the elapse time is worse for pycorrelate.ucorrelate
. Also, have you considering using FFTs to speed up the calculations?
Correlation tends to be a time-consuming task, and it would be nice to have some kind of progress bar to get an estimate for how long it's going to take. This should be rather easy to implement, as we know the length of the arrays. I suggest adding it as a optional parameter to the functions, like
pcorrelate(..., progress=False)
This way, users don't get unexpected output in their terminal, but they can enable this useful feature if they want to. I'm willing to work on this.
In the docs, in the theory section I believe the first formula is lacking
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.