-
Notifications
You must be signed in to change notification settings - Fork 1
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
set up documentation using Documenter.jl #4
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/Manifest.toml | ||
**Manifest.toml | ||
docs/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@book{Gattringer/Lang, | ||
author = {Gattringer/Lang}, | ||
title = {Quantum chromodynamics on the lattice}, | ||
doi = {10.1007/978-3-642-01850-3}, | ||
isbn = {978-3-642-01849-7}, | ||
publisher = {Springer}, | ||
address = {Berlin}, | ||
volume = {788}, | ||
year = {2010} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" | ||
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" | ||
LatSpec = "5648dd92-b909-466b-b6bb-bca0d81a8536" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Documenter | ||
using DocumenterCitations | ||
using LatSpec | ||
|
||
bib = CitationBibliography("LatSpec.bib") | ||
makedocs( | ||
bib, | ||
sitename="LatSpec.jl", | ||
pages = [ | ||
"Home" => "index.md", | ||
"References" => "references.md" | ||
], | ||
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# LatSpec.jl Documentation | ||
|
||
```@meta | ||
CurrentModule = LatSpec | ||
``` | ||
|
||
```@docs | ||
autocor | ||
autotimeexp | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
```@bibliography | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,46 @@ | ||
# Autocorrelation for a specifig lag | ||
function autocor(x::AbstractVector, lag::Integer) | ||
""" | ||
autocor(x,lag) | ||
|
||
Returns autocorrelation function for a distance of lag, i.e. between values of | ||
```x[t]``` and ```x[t+lag]```. The autocorrelation function is normalized such | ||
that ```autocor(x,0) = 1```. This is equvivalent to the quantity | ||
``\\Gamma_X(t)`` of equation (4.61) in [GattringerLang](@cite). | ||
""" | ||
function autocor(x, lag) | ||
# (wasteful in terms of allocations but clear) | ||
z = x .- mean(x) | ||
a = sum(z[1+lag:end].*z[1:end-lag])/sum(z.*z) | ||
return a | ||
end | ||
# Autocorrelation for a automatically choosen number of lags | ||
""" | ||
autocor(x) | ||
|
||
Returns autocorrelation function for a set of lags from ``0`` up to the closest | ||
integer to ``10 \\text{log}_{10}(l)``. Here ``l`` is the number of elements in | ||
```x```. | ||
""" | ||
function autocor(x) | ||
lx = length(x) | ||
# heuristic for choosing a suitable number of lags | ||
lags = collect(0:min(lx-1, round(Int,10*log10(lx)))) | ||
a = zeros(eltype(x),length(lags)) | ||
for i in 1:length(lags) | ||
a[i] = autocor(x, lags[i]) | ||
end | ||
return a | ||
end | ||
# Perform exponential fit of autocorrelation and extract characteristic time | ||
""" | ||
autotimeexp(x) | ||
|
||
Returns ``\\max(1,\\tau)`` where ``\\tau`` is the exponential autocorrelation | ||
time of a series of measurements ``x``. This is obtained by fitting the | ||
autocorrelation function to an exponential function of the form | ||
``A \\exp(\\frac{t}{\\tau})``. | ||
""" | ||
function autotimeexp(O) | ||
a = autocor(O) | ||
@. modelτ(x,p) = abs.(p[2])*exp(-x/p[1]) | ||
x = collect(1:length(a)) | ||
c = curve_fit(modelτ, x, a, ones(2)) | ||
τ = c.param[1] | ||
# if autocorrelation time τ is smaller than 1 return just 1 | ||
return max(one(τ),τ) | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason I miss for calling it
lag
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same name that is being used in StatsBase.jl - we could call it something else. Calling it
time
ort
could be misleading but maybe something likesteps
ortimesteps
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay yes makes sense to stick to something that has already been around for some time.