Setting up repo
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
TITLE: Data Analysis and Machine Learning: Elements of machine learning
|
||||
AUTHOR: Morten Hjorth-Jensen {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo & Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
|
||||
DATE: today
|
||||
|
||||
|
||||
!split
|
||||
===== Introduction =====
|
||||
!bblock
|
||||
|
||||
!eblock
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
\mode<presentation>
|
||||
\usecolortheme[rgb={0.8, 0.2, 0}]{structure}
|
||||
\usefonttheme[onlysmall]{structurebold}
|
||||
|
||||
\setbeamertemplate{navigation symbols}{}
|
||||
%\setbeamertemplate{footline}[frame number]
|
||||
|
||||
\usepackage{tikz}
|
||||
\usetikzlibrary{arrows,shapes,backgrounds,decorations,mindmap}
|
||||
|
||||
\mode
|
||||
<all>
|
||||
@@ -0,0 +1,15 @@
|
||||
\mode<presentation>
|
||||
|
||||
\useoutertheme{smoothbars}
|
||||
\useinnertheme[shadow=true]{rounded}
|
||||
\usecolortheme{orchid}
|
||||
\usecolortheme{whale}
|
||||
\usecolortheme[rgb={0.7, 0.2, 0}]{structure} % (darker red)
|
||||
\useoutertheme{shadow}
|
||||
\usefonttheme[onlysmall]{structurebold}
|
||||
|
||||
\setbeamercolor{title}{use=structure,fg=white,bg=structure.fg}
|
||||
\setbeamerfont{block title}{size={}}
|
||||
|
||||
\mode
|
||||
<all>
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
doconce clean
|
||||
rm -rf *.pdf *.tex ipynb*.tar.gz *.html ._*.html *~ reveal.js Trash README.txt
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
// This function computes the autocorrelation function for
|
||||
// the standard c++ random number generator
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
// output file as global variable
|
||||
ofstream ofile;
|
||||
|
||||
// Main function begins here
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int n;
|
||||
char *outfilename;
|
||||
|
||||
cin >> n;
|
||||
double MCint = 0.; double MCintsqr2=0.;
|
||||
double invers_period = 1./RAND_MAX; // initialise the random number generator
|
||||
srand(time(NULL)); // This produces the so-called seed in MC jargon
|
||||
// Compute the variance and the mean value of the uniform distribution
|
||||
// Compute also the specific values x for each cycle in order to be able to
|
||||
// the covariance and the correlation function
|
||||
// Read in output file, abort if there are too few command-line arguments
|
||||
if( argc <= 2 ){
|
||||
cout << "Bad Usage: " << argv[0] <<
|
||||
" read also output file and number of cycles on same line" << endl;
|
||||
exit(1);
|
||||
}
|
||||
else{
|
||||
outfilename=argv[1];
|
||||
}
|
||||
ofile.open(outfilename);
|
||||
// Get the number of Monte-Carlo samples
|
||||
n = atoi(argv[2]);
|
||||
double *X;
|
||||
X = new double[n];
|
||||
for (int i = 0; i < n; i++){
|
||||
double x = double(rand())*invers_period;
|
||||
X[i] = x;
|
||||
MCint += x;
|
||||
MCintsqr2 += x*x;
|
||||
}
|
||||
double Mean = MCint/((double) n );
|
||||
MCintsqr2 = MCintsqr2/((double) n );
|
||||
double STDev = sqrt(MCintsqr2-Mean*Mean);
|
||||
double Variance = MCintsqr2-Mean*Mean;
|
||||
// Write mean value and standard deviation
|
||||
cout << " Standard deviation= " << STDev << " Integral = " << Mean << endl;
|
||||
|
||||
// Now we compute the autocorrelation function, setting the distance d between two
|
||||
// to a most 1/4 of the total number of cycles
|
||||
double *autocor; autocor = new double[n];
|
||||
for (int j = 0; j < n; j++){
|
||||
double sum = 0.0;
|
||||
for (int k = 0; k < (n-j); k++){
|
||||
sum += (X[k]-Mean)*(X[k+j]-Mean);
|
||||
}
|
||||
autocor[j] = sum/Variance/((double) n );
|
||||
ofile << setiosflags(ios::showpoint | ios::uppercase);
|
||||
ofile << setw(15) << setprecision(8) << j;
|
||||
ofile << setw(15) << setprecision(8) << autocor[j] << endl;
|
||||
}
|
||||
ofile.close(); // close output file
|
||||
return 0;
|
||||
} // end of main program
|
||||
@@ -0,0 +1,76 @@
|
||||
// This function computes the autocorrelation function for
|
||||
// the standard c++ random number generator
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
||||
using namespace std;
|
||||
// output file as global variable
|
||||
ofstream ofile;
|
||||
|
||||
// Main function begins here
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int n;
|
||||
char *outfilename;
|
||||
|
||||
cin >> n;
|
||||
double MCint = 0.; double MCintsqr2=0.;
|
||||
// Initialize the seed and call the Mersienne algo
|
||||
std::random_device rd;
|
||||
std::mt19937_64 gen(rd());
|
||||
// Set up the uniform distribution for x \in [[0, 1]
|
||||
std::uniform_real_distribution<double> RandomNumberGenerator(0.0,1.0);
|
||||
// Compute the variance and the mean value of the uniform distribution
|
||||
// Compute also the specific values x for each cycle in order to be able to
|
||||
// the covariance and the correlation function
|
||||
// Read in output file, abort if there are too few command-line arguments
|
||||
if( argc <= 2 ){
|
||||
cout << "Bad Usage: " << argv[0] <<
|
||||
" read also output file and number of cycles on same line" << endl;
|
||||
exit(1);
|
||||
}
|
||||
else{
|
||||
outfilename=argv[1];
|
||||
}
|
||||
ofile.open(outfilename);
|
||||
// Get the number of Monte-Carlo samples
|
||||
n = atoi(argv[2]);
|
||||
double *X;
|
||||
X = new double[n];
|
||||
for (int i = 0; i < n; i++){
|
||||
double x = RandomNumberGenerator(gen);
|
||||
X[i] = x;
|
||||
MCint += x;
|
||||
MCintsqr2 += x*x;
|
||||
}
|
||||
double Mean = MCint/((double) n );
|
||||
MCintsqr2 = MCintsqr2/((double) n );
|
||||
double STDev = sqrt(MCintsqr2-Mean*Mean);
|
||||
double Variance = MCintsqr2-Mean*Mean;
|
||||
// Write mean value and standard deviation
|
||||
cout << " Standard deviation= " << STDev << " Integral = " << Mean << endl;
|
||||
|
||||
// Now we compute the autocorrelation function, setting the distance d
|
||||
double *autocor; autocor = new double[n];
|
||||
for (int j = 0; j < n; j++){
|
||||
double sum = 0.0;
|
||||
for (int k = 0; k < (n-j); k++){
|
||||
sum += (X[k]-Mean)*(X[k+j]-Mean);
|
||||
}
|
||||
autocor[j] = sum/Variance/((double) n );
|
||||
ofile << setiosflags(ios::showpoint | ios::uppercase);
|
||||
ofile << setw(15) << setprecision(8) << j;
|
||||
ofile << setw(15) << setprecision(8) << autocor[j] << endl;
|
||||
}
|
||||
ofile.close(); // close output file
|
||||
return 0;
|
||||
} // end of main program
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
# Load in data file
|
||||
data = np.loadtxt("autocor.dat")
|
||||
data1 = np.loadtxt("automersenne.dat")
|
||||
# Make arrays containing x-axis and binding energies as function of A
|
||||
x = data[:,0]
|
||||
corr = data[:,1]
|
||||
corr2 = data1[:,1]
|
||||
plt.plot(x, corr ,'ro', x, corr2, 'b')
|
||||
plt.axis([0,1000,-0.2, 1.1])
|
||||
plt.xlabel(r'$d$')
|
||||
plt.ylabel(r'$C_d$')
|
||||
plt.title(r'autocorrelation function for RNG')
|
||||
plt.savefig('autocorr.pdf')
|
||||
plt.show()
|
||||
Executable
+118
@@ -0,0 +1,118 @@
|
||||
#!/bin/sh
|
||||
set -x
|
||||
|
||||
function system {
|
||||
"$@"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "make.sh: unsuccessful command $@"
|
||||
echo "abort!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo 'bash make.sh slides1|slides2'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name=$1
|
||||
rm -f *.tar.gz
|
||||
|
||||
opt="--encoding=utf-8"
|
||||
# Note: Makefile examples contain constructions like ${PROG} which
|
||||
# looks like Mako constructions, but they are not. Use --no_mako
|
||||
# to turn off Mako processing.
|
||||
opt="--no_mako"
|
||||
|
||||
rm -f *.aux
|
||||
|
||||
|
||||
html=${name}-reveal
|
||||
system doconce format html $name --pygments_html_style=perldoc --keep_pygments_html_bg --html_links_in_new_window --html_output=$html $opt
|
||||
system doconce slides_html $html reveal --html_slide_theme=beige
|
||||
|
||||
# Plain HTML documents
|
||||
|
||||
html=${name}-solarized
|
||||
system doconce format html $name --pygments_html_style=perldoc --html_style=solarized3 --html_links_in_new_window --html_output=$html $opt
|
||||
system doconce split_html $html.html --method=space10
|
||||
|
||||
html=${name}
|
||||
system doconce format html $name --pygments_html_style=default --html_style=bloodish --html_links_in_new_window --html_output=$html $opt
|
||||
system doconce split_html $html.html --method=space10
|
||||
|
||||
# Bootstrap style
|
||||
html=${name}-bs
|
||||
system doconce format html $name --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=$html $opt
|
||||
system doconce split_html $html.html --method=split --pagination --nav_button=bottom
|
||||
|
||||
# IPython notebook
|
||||
system doconce format ipynb $name $opt
|
||||
|
||||
# LaTeX Beamer slides
|
||||
beamertheme=red_plain
|
||||
system doconce format pdflatex $name --latex_title_layout=beamer --latex_table_format=footnotesize $opt
|
||||
system doconce ptex2tex $name envir=minted
|
||||
# Add special packages
|
||||
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
|
||||
system doconce slides_beamer $name --beamer_slide_theme=$beamertheme
|
||||
system pdflatex -shell-escape ${name}
|
||||
system pdflatex -shell-escape ${name}
|
||||
cp $name.pdf ${name}-beamer.pdf
|
||||
cp $name.tex ${name}-beamer.tex
|
||||
|
||||
# Handouts
|
||||
system doconce format pdflatex $name --latex_title_layout=beamer --latex_table_format=footnotesize $opt
|
||||
system doconce ptex2tex $name envir=minted
|
||||
# Add special packages
|
||||
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
|
||||
system doconce slides_beamer $name --beamer_slide_theme=red_shadow --handout
|
||||
system pdflatex -shell-escape $name
|
||||
pdflatex -shell-escape $name
|
||||
pdflatex -shell-escape $name
|
||||
pdfnup --nup 2x3 --frame true --delta "1cm 1cm" --scale 0.9 --outfile ${name}-beamer-handouts2x3.pdf ${name}.pdf
|
||||
rm -f ${name}.pdf
|
||||
|
||||
# Ordinary plain LaTeX document
|
||||
rm -f *.aux # important after beamer
|
||||
system doconce format pdflatex $name --minted_latex_style=trac --latex_admon=paragraph $opt
|
||||
system doconce ptex2tex $name envir=minted
|
||||
# Add special packages
|
||||
doconce subst "% Add user's preamble" "\g<1>\n\\usepackage{simplewick}" $name.tex
|
||||
doconce replace 'section{' 'section*{' $name.tex
|
||||
pdflatex -shell-escape $name
|
||||
pdflatex -shell-escape $name
|
||||
mv -f $name.pdf ${name}-minted.pdf
|
||||
cp $name.tex ${name}-plain-minted.tex
|
||||
|
||||
|
||||
|
||||
# Publish
|
||||
dest=../../pub
|
||||
if [ ! -d $dest/$name ]; then
|
||||
mkdir $dest/$name
|
||||
mkdir $dest/$name/pdf
|
||||
mkdir $dest/$name/html
|
||||
mkdir $dest/$name/ipynb
|
||||
fi
|
||||
cp ${name}*.pdf $dest/$name/pdf
|
||||
cp -r ${name}*.html ._${name}*.html reveal.js $dest/$name/html
|
||||
|
||||
# Figures: cannot just copy link, need to physically copy the files
|
||||
if [ -d fig-${name} ]; then
|
||||
if [ ! -d $dest/$name/html/fig-$name ]; then
|
||||
mkdir $dest/$name/html/fig-$name
|
||||
fi
|
||||
cp -r fig-${name}/* $dest/$name/html/fig-$name
|
||||
fi
|
||||
|
||||
cp ${name}.ipynb $dest/$name/ipynb
|
||||
ipynb_tarfile=ipynb-${name}-src.tar.gz
|
||||
if [ ! -f ${ipynb_tarfile} ]; then
|
||||
cat > README.txt <<EOF
|
||||
This IPython notebook ${name}.ipynb does not require any additional
|
||||
programs.
|
||||
EOF
|
||||
tar czf ${ipynb_tarfile} README.txt
|
||||
fi
|
||||
cp ${ipynb_tarfile} $dest/$name/ipynb
|
||||
Reference in New Issue
Block a user