How to Calculate Correlation Time Using Numpy for Monte Carlo Simulations?

AI Thread Summary
To calculate correlation time for a Monte Carlo simulation of the 2D Ising Model using NumPy, the user seeks methods to analyze average magnetization data. They mention the numpy.correlate function, which computes cross-correlation but does not provide a correlation function directly. Suggestions include writing a custom correlation function if built-in options are insufficient. Alternatively, linear regression is proposed as a potential solution for analyzing the data. The discussion emphasizes the need for effective tools to calculate uncertainty in magnetization measurements.
xperrylinn
Messages
3
Reaction score
0
I'm creating a Monte Carlo simulation of the 2D Ising Model for a graduate course in computational materials science. Part of the assignment is to calculate the uncertainty in the calculation of the average magnetization per spin. To do so, we are told to find the correlation time for our data set of average magnetization vs. number of spin flip attempts. We are instructed to do this by using built in methods provided by either Matlab, Mathematica, or in my case numpy since I'm coding in python to provide us with a correlation function which can be used in further steps to calculate the correlation time.

I've take a look at the numpy library and there is a feature called correlate. numpy.correlate that takes in two arrays, and calculates the cross correlation between the two data sets are returns a constant value. I don't see anything in the numpy library that returns a correlation function. Any suggestions on how to proceed? Thanks..
 
Physics news on Phys.org
If you can't find one, why don't you write your own?! It is not that difficult.

If you really can't figure it out, why don't you try linear regression
 
Back
Top