Skip to content

Commit 4dfe66a

Browse files
committed
integrated new routine
"book_content.md" was moved to "LoC.md" (list of contents) and edited; "construct_toc.py" was integrated into "update.py", a copy is kept at "update_ToC.py". From now on, new proofs and definitions should be entered into "LoC.md", not "ToC.md"
1 parent 9d47505 commit 4dfe66a

4 files changed

Lines changed: 105 additions & 35 deletions

File tree

book_content.md renamed to I/LoC.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
layout: page
3+
title: "List of Contents"
4+
---
5+
6+
7+
Templates: **[Proof](/P/-temp-)***[Definition](/D/-temp-)*
8+
9+
110
# Chapter I: General Theorems
211
## Probability theory
312
### Random experiments

I/ToC.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: "Table of Contents"
1212
<br>
1313
<h3 id="General Theorems">Chapter I: General Theorems</h3>
1414

15-
15+
1616
1. <p id="Probability theory">Probability theory</p>
1717

1818
<p id="Random experiments"></p>
@@ -250,7 +250,7 @@ title: "Table of Contents"
250250
&emsp;&ensp; 1.21.7. **[First central moment is zero](/P/momcent-1st)** <br>
251251
&emsp;&ensp; 1.21.8. **[Second central moment is variance](/P/momcent-2nd)** <br>
252252
&emsp;&ensp; 1.21.9. *[Standardized moment](/D/mom-stand)* <br>
253-
253+
254254
2. <p id="Information theory">Information theory</p>
255255

256256
<p id="Shannon entropy"></p>
@@ -303,7 +303,7 @@ title: "Table of Contents"
303303
&emsp;&ensp; 2.5.8. **[Invariance under parameter transformation](/P/kl-inv)** <br>
304304
&emsp;&ensp; 2.5.9. **[Relation to discrete entropy](/P/kl-ent)** <br>
305305
&emsp;&ensp; 2.5.10. **[Relation to differential entropy](/P/kl-dent)** <br>
306-
306+
307307
3. <p id="Estimation theory">Estimation theory</p>
308308

309309
<p id="Basic concepts of estimation"></p>
@@ -320,7 +320,7 @@ title: "Table of Contents"
320320
3.3. Interval estimates <br>
321321
&emsp;&ensp; 3.3.1. *[Confidence interval](/D/ci)* <br>
322322
&emsp;&ensp; 3.3.2. **[Construction of confidence intervals using Wilks' theorem](/P/ci-wilks)** <br>
323-
323+
324324
4. <p id="Frequentist statistics">Frequentist statistics</p>
325325

326326
<p id="Likelihood theory"></p>
@@ -356,7 +356,7 @@ title: "Table of Contents"
356356
&emsp;&ensp; 4.3.11. **[Distribution of p-value under null hypothesis](/P/pval-h0)** <br>
357357
&emsp;&ensp; 4.3.12. *[Minimum detectable effect](/D/mde)* <br>
358358
&emsp;&ensp; 4.3.13. *[Minimum required sample size](/D/mrss)* <br>
359-
359+
360360
5. <p id="Bayesian statistics">Bayesian statistics</p>
361361

362362
<p id="Probabilistic modeling"></p>
@@ -398,7 +398,7 @@ title: "Table of Contents"
398398
&emsp;&ensp; 5.3.5. *[Variational Bayes](/D/vb)* <br>
399399
&emsp;&ensp; 5.3.6. **[Decomposition of the free energy](/P/fren-dec)** <br>
400400
&emsp;&ensp; 5.3.7. **[Free energy is lower bound on log model evidence](/P/fren-lme)** <br>
401-
401+
402402
6. <p id="Machine learning">Machine learning</p>
403403

404404
<p id="Scoring rules"></p>
@@ -415,7 +415,7 @@ title: "Table of Contents"
415415
<br>
416416
<h3 id="Probability Distributions">Chapter II: Probability Distributions</h3>
417417

418-
418+
419419
1. <p id="Univariate discrete distributions">Univariate discrete distributions</p>
420420

421421
<p id="Discrete uniform distribution"></p>
@@ -467,7 +467,7 @@ title: "Table of Contents"
467467
&emsp;&ensp; 1.5.3. **[Mean](/P/poiss-mean)** <br>
468468
&emsp;&ensp; 1.5.4. **[Variance](/P/poiss-var)** <br>
469469
&emsp;&ensp; 1.5.5. **[Shannon entropy](/P/poiss-ent)** <br>
470-
470+
471471
2. <p id="Multivariate discrete distributions">Multivariate discrete distributions</p>
472472

473473
<p id="Categorical distribution"></p>
@@ -487,7 +487,7 @@ title: "Table of Contents"
487487
&emsp;&ensp; 2.2.5. **[Covariance](/P/mult-cov)** <br>
488488
&emsp;&ensp; 2.2.6. **[Shannon entropy](/P/mult-ent)** <br>
489489
&emsp;&ensp; 2.2.7. **[Marginal distributions](/P/mult-marg)** <br>
490-
490+
491491
3. <p id="Univariate continuous distributions">Univariate continuous distributions</p>
492492

493493
<p id="Continuous uniform distribution"></p>
@@ -637,7 +637,7 @@ title: "Table of Contents"
637637
&emsp;&ensp; 3.11.5. **[Variance](/P/exg-var)** <br>
638638
&emsp;&ensp; 3.11.6. **[Skewness](/P/exg-skew)** <br>
639639
&emsp;&ensp; 3.11.7. **[Method of moments](/P/exg-mome)** <br>
640-
640+
641641
4. <p id="Multivariate continuous distributions">Multivariate continuous distributions</p>
642642

643643
<p id="Multivariate normal distribution"></p>
@@ -696,7 +696,7 @@ title: "Table of Contents"
696696
&emsp;&ensp; 4.5.2. **[Probability density function](/P/dir-pdf)** <br>
697697
&emsp;&ensp; 4.5.3. **[Kullback-Leibler divergence](/P/dir-kl)** <br>
698698
&emsp;&ensp; 4.5.4. **[Exceedance probabilities](/P/dir-ep)** <br>
699-
699+
700700
5. <p id="Matrix-variate continuous distributions">Matrix-variate continuous distributions</p>
701701

702702
<p id="Matrix-normal distribution"></p>
@@ -730,7 +730,7 @@ title: "Table of Contents"
730730
<br>
731731
<h3 id="Statistical Models">Chapter III: Statistical Models</h3>
732732

733-
733+
734734
1. <p id="Univariate normal data">Univariate normal data</p>
735735

736736
<p id="Univariate Gaussian"></p>
@@ -873,7 +873,7 @@ title: "Table of Contents"
873873
&emsp;&ensp; 1.7.2. **[Posterior distribution](/P/blrkc-post)** <br>
874874
&emsp;&ensp; 1.7.3. **[Log model evidence](/P/blrkc-lme)** <br>
875875
&emsp;&ensp; 1.7.4. **[Accuracy and complexity](/P/blrkc-anc)** <br>
876-
876+
877877
2. <p id="Multivariate normal data">Multivariate normal data</p>
878878

879879
<p id="Multivariate Gaussian"></p>
@@ -915,7 +915,7 @@ title: "Table of Contents"
915915
&emsp;&ensp; 2.5.1. **[Conjugate prior distribution](/P/mblr-prior)** <br>
916916
&emsp;&ensp; 2.5.2. **[Posterior distribution](/P/mblr-post)** <br>
917917
&emsp;&ensp; 2.5.3. **[Log model evidence](/P/mblr-lme)** <br>
918-
918+
919919
3. <p id="Count data">Count data</p>
920920

921921
<p id="Binomial observations"></p>
@@ -961,7 +961,7 @@ title: "Table of Contents"
961961
&emsp;&ensp; 3.4.3. **[Conjugate prior distribution](/P/poissexp-prior)** <br>
962962
&emsp;&ensp; 3.4.4. **[Posterior distribution](/P/poissexp-post)** <br>
963963
&emsp;&ensp; 3.4.5. **[Log model evidence](/P/poissexp-lme)** <br>
964-
964+
965965
4. <p id="Frequency data">Frequency data</p>
966966

967967
<p id="Beta-distributed data"></p>
@@ -978,7 +978,7 @@ title: "Table of Contents"
978978
4.3. Beta-binomial data <br>
979979
&emsp;&ensp; 4.3.1. *[Definition](/D/betabin-data)* <br>
980980
&emsp;&ensp; 4.3.2. **[Method of moments](/P/betabin-mome)** <br>
981-
981+
982982
5. <p id="Categorical data">Categorical data</p>
983983

984984
<p id="Logistic regression"></p>
@@ -991,7 +991,7 @@ title: "Table of Contents"
991991
<br>
992992
<h3 id="Model Selection">Chapter IV: Model Selection</h3>
993993

994-
994+
995995
1. <p id="Goodness-of-fit measures">Goodness-of-fit measures</p>
996996

997997
<p id="Residual variance"></p>
@@ -1024,7 +1024,7 @@ title: "Table of Contents"
10241024
&emsp;&ensp; 1.4.1. *[Definition](/D/snr)* <br>
10251025
&emsp;&ensp; 1.4.2. **[Relationship to coefficient of determination](/P/snr-rsq)** <br>
10261026
&emsp;&ensp; 1.4.3. **[Relationship to maximum log-likelihood](/P/snr-mll)** <br>
1027-
1027+
10281028
2. <p id="Classical information criteria">Classical information criteria</p>
10291029

10301030
<p id="Akaike information criterion"></p>
@@ -1043,7 +1043,7 @@ title: "Table of Contents"
10431043
2.3. Deviance information criterion <br>
10441044
&emsp;&ensp; 2.3.1. *[Definition](/D/dic)* <br>
10451045
&emsp;&ensp; 2.3.2. *[Deviance](/D/dev)* <br>
1046-
1046+
10471047
3. <p id="Bayesian model selection">Bayesian model selection</p>
10481048

10491049
<p id="Model evidence"></p>

update.py

Lines changed: 77 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
E-Mail: joram.soch@bccn-berlin.de
1818
1919
First edit: 2019-09-27 12:55:00
20-
Last edit: 2025-10-31 15:35:00
20+
Last edit: 2025-12-12 16:06:00
2121
"""
2222

2323

@@ -141,36 +141,97 @@
141141
print(' - ' + str(num_def) + ' files found in definition directory!')
142142

143143

144-
# Table of Contents: read index file
144+
# List of Contents: read index file
145145
#-----------------------------------------------------------------------------#
146-
print('\n1. Table of Contents:')
147-
f1 = open('I/ToC.md', 'r')
148-
ToCs = f1.readlines()
149-
f1.close()
146+
print('\n1a.List of Contents:')
147+
f1a = open('I/LoC.md', 'r')
148+
LoCs = f1a.readlines()
149+
f1a.close()
150150

151-
# Table of Contents: check for proof Shortcuts
151+
# List of Contents: check for proof shortcuts
152152
#-----------------------------------------------------------------------------#
153153
incl = np.zeros(num_pr, dtype=bool)
154154
for (i, proof) in enumerate(proofs):
155-
for line in ToCs:
155+
for line in LoCs:
156156
if line.find('(/P/' + proof['shortcut'] + ')') > -1:
157157
incl[i] = True
158158
if ~incl[i]:
159-
print(' - WARNING: proof "' + proof['shortcut'] + '" is not in table of contents!')
160-
if all(incl):
161-
print(' - ' + str(sum(incl)) + ' proofs found in table of contents!')
159+
print(' - WARNING: proof "' + proof['shortcut'] + '" is not in list of contents!')
160+
print(' - ' + str(sum(incl)) + ' proofs found in list of contents!')
162161

163-
# Table of Contents: check for definition Shortcuts
162+
# List of Contents: check for definition shortcuts
164163
#-----------------------------------------------------------------------------#
165164
incl = np.zeros(num_def, dtype=bool)
166165
for (i, definition) in enumerate(defs):
167-
for line in ToCs:
166+
for line in LoCs:
168167
if line.find('(/D/' + definition['shortcut'] + ')') > -1:
169168
incl[i] = True
170169
if ~incl[i]:
171-
print(' - WARNING: definition "' + definition['shortcut'] + '" is not in table of contents!')
172-
if all(incl):
173-
print(' - ' + str(sum(incl)) + ' definitions found in table of contents!')
170+
print(' - WARNING: definition "' + definition['shortcut'] + '" is not in list of contents!')
171+
print(' - ' + str(sum(incl)) + ' definitions found in list of contents!')
172+
173+
174+
# Table of Contents: prepare index file
175+
#-----------------------------------------------------------------------------#
176+
print('\n1b.Table of Contents:')
177+
print(' - generating from list of contents ...')
178+
f1b = open('I/ToC.md', 'w')
179+
f1b.write('---\nlayout: page\ntitle: "Table of Contents"\n---\n\n\n')
180+
f1b.write('**[Proofs](/P/-temp-)** are printed in **bold** – *[Definitions](/D/-temp-)* are set in *italics* <br>\n')
181+
f1b.write('**Proofs**: [by Number](/I/PbN), [by Topic](/I/PbT) – *Definitions*: [by Number](/I/DbN), [by Topic](/I/DbT) <br>\n')
182+
f1b.write('<u>Specials:</u> [General Theorems](/S/ChI), [Probability Distributions](/S/ChII), [Statistical Models](/S/ChIII), [Model Selection Criteria](/S/ChIV) <br>\n')
183+
184+
# Table of Contents: write all chapters
185+
#-----------------------------------------------------------------------------#
186+
roman = ['I', 'II', 'III', 'IV', 'V']
187+
num_chap = 0
188+
num_sect = 0
189+
num_ssec = 0
190+
num_item = 0
191+
192+
# check list of contents
193+
for line in LoCs:
194+
line = line.strip()
195+
196+
# this is a new chapter
197+
if line.startswith("# Chapter "):
198+
num_sect = 0
199+
num_chap = num_chap + 1
200+
curr_chap = line[line.find(': ')+2:].strip()
201+
f1b.write('\n\n<br>\n')
202+
f1b.write('<h3 id="{}">Chapter {}: {}</h3>\n\n'. \
203+
format(curr_chap, roman[num_chap-1], curr_chap))
204+
205+
# this is a new section
206+
elif line.startswith('## '):
207+
num_ssec = 0
208+
num_sect = num_sect + 1
209+
curr_sect = line[line.find('## ')+3:].strip()
210+
f1b.write('\n')
211+
f1b.write('{}. <p id="{}">{}</p>\n'. \
212+
format(num_sect, curr_sect, curr_sect))
213+
214+
# this is a new subsection
215+
elif line.startswith('### '):
216+
num_item = 0
217+
num_ssec = num_ssec + 1
218+
curr_ssec = line[line.find('### ')+4:].strip()
219+
f1b.write(' \n')
220+
f1b.write(' <p id="{}"></p>\n'.format(curr_ssec))
221+
f1b.write(' {}.{}. {} <br>\n'. \
222+
format(num_sect, num_ssec, curr_ssec))
223+
224+
# this is a new item
225+
elif line.startswith('- '):
226+
num_item = num_item + 1
227+
curr_item = line[line.find('- ')+2:].strip()
228+
f1b.write(' &emsp;&ensp; {}.{}.{}. {} <br>\n'. \
229+
format(num_sect, num_ssec, num_item, curr_item))
230+
231+
f1b.close()
232+
del num_chap, num_sect, num_ssec, num_item
233+
del curr_chap, curr_sect, curr_ssec, curr_item
234+
print(' successfully written to disk!')
174235

175236

176237
# Proof by Number: prepare index file
File renamed without changes.

0 commit comments

Comments
 (0)