Compare commits
No commits in common. "main" and "tut4-v1.2" have entirely different histories.
@ -1,3 +1,4 @@
|
|||||||
$pdflatex="pdflatex -shell-escape -interaction=nonstopmode -synctex=1 %O %S";
|
$pdflatex="pdflatex -shell-escape -interaction=nonstopmode -synctex=1 %O %S";
|
||||||
$out_dir = 'build';
|
$out_dir = 'build';
|
||||||
$pdf_mode = 1;
|
$pdf_mode = 1;
|
||||||
|
|
||||||
|
|||||||
16
Makefile
16
Makefile
@ -1,25 +1,19 @@
|
|||||||
PRESENTATIONS := $(patsubst src/%/presentation.tex,build/presentation_%.pdf,$(wildcard src/*/presentation.tex))
|
PRESENTATIONS := $(patsubst src/%/presentation.tex,build/presentation_%.pdf,$(wildcard src/*/presentation.tex))
|
||||||
HANDOUTS := $(patsubst build/presentation_%.pdf,build/presentation_%_handout.pdf,$(PRESENTATIONS))
|
HANDOUTS := $(patsubst build/presentation_%.pdf,build/presentation_%_handout.pdf,$(PRESENTATIONS))
|
||||||
|
|
||||||
RC_PDFLATEX := $(shell grep '$$pdflatex' .latexmkrc \
|
|
||||||
| sed -e 's/.*"\(.*\)".*/\1/' -e 's/%S//' -e 's/%O//')
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(PRESENTATIONS) $(HANDOUTS)
|
all: $(PRESENTATIONS) $(HANDOUTS)
|
||||||
|
|
||||||
build/presentation_%.pdf: src/%/presentation.tex build/prepared
|
build/presentation_%.pdf: src/%/presentation.tex build/prepared
|
||||||
TEXINPUTS=./lib/cel-slides-template-2025:$(dir $<):$$TEXINPUTS \
|
TEXINPUTS=./lib/cel-slides-template-2025:$$TEXINPUTS latexmk $<
|
||||||
latexmk -outdir=build/$* $<
|
mv build/presentation.pdf $@
|
||||||
cp build/$*/presentation.pdf $@
|
|
||||||
|
|
||||||
build/presentation_%_handout.pdf: src/%/presentation.tex build/prepared
|
build/presentation_%_handout.pdf: src/%/presentation.tex build/prepared
|
||||||
TEXINPUTS=./lib/cel-slides-template-2025:$(dir $<):$$TEXINPUTS \
|
TEXINPUTS=./lib/cel-slides-template-2025:$$TEXINPUTS latexmk -pdflatex='pdflatex %O "\def\ishandout{1}\input{%S}"' $<
|
||||||
latexmk -outdir=build/$*_handout \
|
mv build/presentation.pdf $@
|
||||||
-pdflatex='$(RC_PDFLATEX) %O "\def\ishandout{1}\input{%S}"' $<
|
|
||||||
cp build/$*_handout/presentation.pdf $@
|
|
||||||
|
|
||||||
build/prepared:
|
build/prepared:
|
||||||
mkdir build
|
mkdir -p build
|
||||||
touch build/prepared
|
touch build/prepared
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,38 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from numpy.typing import NDArray
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
|
|
||||||
def twodim_array_to_pgfplots_table_string(a: NDArray):
|
|
||||||
return (
|
|
||||||
" \\\\\n".join([" ".join([str(vali) for vali in val]) for val in a]) + "\\\\\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# Parse command line arguments
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("--correlation", "-c", type=np.float32, required=True)
|
|
||||||
parser.add_argument("-N", type=np.int32, required=True)
|
|
||||||
parser.add_argument("--plot", "-p", action="store_true")
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Generate & plot data
|
|
||||||
|
|
||||||
means = np.array([0, 0])
|
|
||||||
cov = np.array([[1, args.correlation], [args.correlation, 1]])
|
|
||||||
|
|
||||||
x = np.random.multivariate_normal(means, cov, size=args.N)
|
|
||||||
|
|
||||||
print(twodim_array_to_pgfplots_table_string(x))
|
|
||||||
|
|
||||||
if args.plot:
|
|
||||||
plt.scatter(x[:, 0], x[:, 1])
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import argparse
|
|
||||||
import numpy as np
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from scipy.special import binom
|
|
||||||
|
|
||||||
|
|
||||||
def array_to_pgfplots_table_string(a):
|
|
||||||
return " ".join([f"({k}, {val})" for (k, val) in enumerate(a)]) + f" ({len(a)}, 0)"
|
|
||||||
|
|
||||||
|
|
||||||
def P_binom(N, p, k):
|
|
||||||
return binom(N, k) * p**k * (1 - p) ** (N - k)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# Parse command line arguments
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("-N", type=np.int32, required=True)
|
|
||||||
parser.add_argument("-p", type=np.float32, required=True)
|
|
||||||
parser.add_argument("--show", "-s", action="store_true")
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Generate and show data
|
|
||||||
|
|
||||||
N = args.N
|
|
||||||
p = args.p
|
|
||||||
|
|
||||||
bars = np.array([P_binom(N, p, k) for k in range(N + 1)])
|
|
||||||
|
|
||||||
print(array_to_pgfplots_table_string(bars))
|
|
||||||
|
|
||||||
if args.show:
|
|
||||||
plt.stem(bars)
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user