Some progress on BACH, added pseudocode for better understanding
This commit is contained in:
parent
cd72a820f2
commit
dd83a902f8
7 changed files with 296 additions and 2 deletions
176
Session.vim
Normal file
176
Session.vim
Normal file
|
|
@ -0,0 +1,176 @@
|
||||||
|
let SessionLoad = 1
|
||||||
|
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
|
||||||
|
let v:this_session=expand("<sfile>:p")
|
||||||
|
silent only
|
||||||
|
silent tabonly
|
||||||
|
cd ~/thesis
|
||||||
|
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
||||||
|
let s:wipebuf = bufnr('%')
|
||||||
|
endif
|
||||||
|
let s:shortmess_save = &shortmess
|
||||||
|
if &shortmess =~ 'A'
|
||||||
|
set shortmess=aoOA
|
||||||
|
else
|
||||||
|
set shortmess=aoO
|
||||||
|
endif
|
||||||
|
badd +128 content/BACH.typ
|
||||||
|
badd +1 glossary.typ
|
||||||
|
badd +1 bibliography.bib
|
||||||
|
badd +0 \$
|
||||||
|
badd +6 pseudocode/bach_1.typ
|
||||||
|
badd +265 content/SMHD.typ
|
||||||
|
badd +7 pseudocode/bach_find_best_appr.typ
|
||||||
|
argglobal
|
||||||
|
%argdel
|
||||||
|
set stal=2
|
||||||
|
tabnew +setlocal\ bufhidden=wipe
|
||||||
|
tabnew +setlocal\ bufhidden=wipe
|
||||||
|
tabnew +setlocal\ bufhidden=wipe
|
||||||
|
tabrewind
|
||||||
|
edit content/BACH.typ
|
||||||
|
argglobal
|
||||||
|
balt content/SMHD.typ
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 164 - ((38 * winheight(0) + 25) / 50)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 164
|
||||||
|
normal! 0
|
||||||
|
tabnext
|
||||||
|
edit glossary.typ
|
||||||
|
argglobal
|
||||||
|
balt content/BACH.typ
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 1 - ((0 * winheight(0) + 25) / 50)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 1
|
||||||
|
normal! 0
|
||||||
|
tabnext
|
||||||
|
edit bibliography.bib
|
||||||
|
argglobal
|
||||||
|
balt glossary.typ
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 1 - ((0 * winheight(0) + 25) / 50)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 1
|
||||||
|
normal! 015|
|
||||||
|
tabnext
|
||||||
|
edit pseudocode/bach_1.typ
|
||||||
|
let s:save_splitbelow = &splitbelow
|
||||||
|
let s:save_splitright = &splitright
|
||||||
|
set splitbelow splitright
|
||||||
|
wincmd _ | wincmd |
|
||||||
|
split
|
||||||
|
1wincmd k
|
||||||
|
wincmd w
|
||||||
|
let &splitbelow = s:save_splitbelow
|
||||||
|
let &splitright = s:save_splitright
|
||||||
|
wincmd t
|
||||||
|
let s:save_winminheight = &winminheight
|
||||||
|
let s:save_winminwidth = &winminwidth
|
||||||
|
set winminheight=0
|
||||||
|
set winheight=1
|
||||||
|
set winminwidth=0
|
||||||
|
set winwidth=1
|
||||||
|
exe '1resize ' . ((&lines * 25 + 26) / 53)
|
||||||
|
exe 'vert 1resize ' . ((&columns * 129 + 105) / 211)
|
||||||
|
exe '2resize ' . ((&lines * 24 + 26) / 53)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 129 + 105) / 211)
|
||||||
|
argglobal
|
||||||
|
balt bibliography.bib
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 16 - ((15 * winheight(0) + 12) / 25)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 16
|
||||||
|
normal! 0
|
||||||
|
wincmd w
|
||||||
|
argglobal
|
||||||
|
if bufexists(fnamemodify("pseudocode/bach_find_best_appr.typ", ":p")) | buffer pseudocode/bach_find_best_appr.typ | else | edit pseudocode/bach_find_best_appr.typ | endif
|
||||||
|
if &buftype ==# 'terminal'
|
||||||
|
silent file pseudocode/bach_find_best_appr.typ
|
||||||
|
endif
|
||||||
|
balt pseudocode/bach_1.typ
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal fen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 7 - ((6 * winheight(0) + 12) / 24)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 7
|
||||||
|
normal! 031|
|
||||||
|
wincmd w
|
||||||
|
exe '1resize ' . ((&lines * 25 + 26) / 53)
|
||||||
|
exe 'vert 1resize ' . ((&columns * 129 + 105) / 211)
|
||||||
|
exe '2resize ' . ((&lines * 24 + 26) / 53)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 129 + 105) / 211)
|
||||||
|
tabnext 1
|
||||||
|
set stal=1
|
||||||
|
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
||||||
|
silent exe 'bwipe ' . s:wipebuf
|
||||||
|
endif
|
||||||
|
unlet! s:wipebuf
|
||||||
|
set winheight=1 winwidth=20
|
||||||
|
let &shortmess = s:shortmess_save
|
||||||
|
let &winminheight = s:save_winminheight
|
||||||
|
let &winminwidth = s:save_winminwidth
|
||||||
|
let s:sx = expand("<sfile>:p:r")."x.vim"
|
||||||
|
if filereadable(s:sx)
|
||||||
|
exe "source " . fnameescape(s:sx)
|
||||||
|
endif
|
||||||
|
let &g:so = s:so_save | let &g:siso = s:siso_save
|
||||||
|
set hlsearch
|
||||||
|
nohlsearch
|
||||||
|
doautoall SessionLoadPost
|
||||||
|
unlet SessionLoad
|
||||||
|
" vim: set ft=vim :
|
||||||
|
|
@ -38,3 +38,11 @@
|
||||||
year={2018},
|
year={2018},
|
||||||
organization={IEEE}
|
organization={IEEE}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@book{schmutz,
|
||||||
|
title={Introduction to mathematical statistics},
|
||||||
|
author={Hogg, Robert V and McKean, Joseph W and Craig, Allen T and others},
|
||||||
|
year={2013},
|
||||||
|
publisher={Pearson Education India}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ Later we will be able to show that a higher number of summands for $z$ can provi
|
||||||
We will define $z$ from now on as:
|
We will define $z$ from now on as:
|
||||||
$
|
$
|
||||||
z = x_1 dot h_1 plus x_2 dot h_2 plus x_3 dot h_3.
|
z = x_1 dot h_1 plus x_2 dot h_2 plus x_3 dot h_3.
|
||||||
$
|
$<eq:z_eq>
|
||||||
|
|
||||||
We can now find the optimal linear combination $z_"opt"$ by finding the minimum of all distances to all optimal points defined as $bold(cal(o))$.
|
We can now find the optimal linear combination $z_"opt"$ by finding the minimum of all distances to all optimal points defined as $bold(cal(o))$.
|
||||||
The matrix that contains the distances of all linear combinations $bold(z)$ to all optimal points $bold(cal(o))$ is defined as: $bold(cal(A))$ with its entries $a_"ij" = abs(z_"i" - o_"j")$.\
|
The matrix that contains the distances of all linear combinations $bold(z)$ to all optimal points $bold(cal(o))$ is defined as: $bold(cal(A))$ with its entries $a_"ij" = abs(z_"i" - o_"j")$.\
|
||||||
|
|
@ -119,7 +119,46 @@ $
|
||||||
z_"opt" = op("argmin")(bold(cal(A)))
|
z_"opt" = op("argmin")(bold(cal(A)))
|
||||||
= op("argmin")(mat(delim: "[", a_("00"), ..., a_("i0"); dots.v, dots.down, " "; a_"0j", " ", a_"ij" )).
|
= op("argmin")(mat(delim: "[", a_("00"), ..., a_("i0"); dots.v, dots.down, " "; a_"0j", " ", a_"ij" )).
|
||||||
$
|
$
|
||||||
|
#figure(
|
||||||
|
kind: "algorithm",
|
||||||
|
supplement: [Algorithm],
|
||||||
|
include("../pseudocode/bach_find_best_appr.typ")
|
||||||
|
)<alg:best_appr>
|
||||||
|
|
||||||
=== Algorithm definition
|
@alg:best_appr shows a programmatic approach to find the set of weights for the best approximation. The algorithm returns a tuple consisting of the weight combination $bold(h)$ and the resulting value of the linear combination $z_"opt"$
|
||||||
|
=== Realization of center point approximation
|
||||||
|
|
||||||
|
As described earlier, we can define the ideal possible positions for the linear combination $z_"opt"$ to be the centers of the quantizer steps.
|
||||||
|
Because the superposition of different linear combinations of normal distributions corresponds to a Gaussian Mixture Model, wherein finding the ideal set of points $bold(cal(o))$ analytically is impossible.
|
||||||
|
|
||||||
|
Instead, we will first estimate $bold(cal(o))$ based on the normal distribution parameters after performing multiple convolutions with the input distribution $X$.
|
||||||
|
The parameters of a multiple convoluted normal distribution is defined as:
|
||||||
|
$
|
||||||
|
sum_(i=1)^(n) cal(N)(mu_i, sigma_i^2) tilde cal(N)(sum_(i=1)^n mu_i, sum_(i=1)^n sigma_i^2),
|
||||||
|
$
|
||||||
|
while $n$ defines the number of convolutions performed @schmutz.
|
||||||
|
|
||||||
|
With this definition, we can define the parameters of the probability distribution $Z$ of the linear combinations $z$ based on the parameters of $X$, $mu_X$ and $sigma_X$:
|
||||||
|
|
||||||
|
$
|
||||||
|
Z(mu_Z, sigma_Z^2) = Z(sum_(i=1^n) mu_X, sum_(i=1)^n sigma_X^2)
|
||||||
|
$
|
||||||
|
|
||||||
|
The parameters $mu_Z$ and $sigma_Z$ allow us to apply an inverse CDF on a multi-bit quantizer $cal(Q)(2, tilde(x))$ defined in the tilde-domain.
|
||||||
|
Our initial values for $bold(cal(o))_"first"$ can now be defined as the centers of the steps of the transformed quantizer function $cal(Q)(2, x)$.
|
||||||
|
These points can be found easily but for the outermost center points whose quantizer steps have a bound $plus.minus infinity$.\
|
||||||
|
However, we can still find these two remaining center points by artificially defining the outermost bounds of the quantizer as $frac(1, 2^M dot 4)$ and $frac((2^M dot 4)-1, 2^M dot 4)$ in the tilde-domain and also apply the inverse CDF to them.
|
||||||
|
|
||||||
|
#scale(x: 90%, y: 90%)[
|
||||||
|
#figure(
|
||||||
|
include("../graphics/quantizers/two-bit-enroll-real.typ"),
|
||||||
|
caption: [Quantizer for the distribution resulting a triple convolution with distribution parameters $mu_X=0$ and $sigma_X=1$ with marked center points of the quantizer steps]
|
||||||
|
)<fig:two-bit-enroll-find-centers>]
|
||||||
|
|
||||||
|
We can now use an iterative algorithm that alternates between optimizing the quantizing bounds of $cal(Q)$ and our vector of optimal points $bold(cal(o))_"first"$.
|
||||||
|
|
||||||
|
#figure(
|
||||||
|
kind: "algorithm",
|
||||||
|
supplement: [Algorithm],
|
||||||
|
include("../pseudocode/bach_1.typ")
|
||||||
|
)
|
||||||
|
|
|
||||||
43
graphics/quantizers/two-bit-enroll-real.typ
Normal file
43
graphics/quantizers/two-bit-enroll-real.typ
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#import "@preview/cetz:0.2.2": canvas, plot, decorations, draw
|
||||||
|
|
||||||
|
#let line_style = (stroke: (paint: black, thickness: 2pt))
|
||||||
|
#let dashed = (stroke: (dash: "dashed"))
|
||||||
|
#canvas({
|
||||||
|
plot.plot(size: (8,6),
|
||||||
|
legend: "legend.south",
|
||||||
|
name: "plot",
|
||||||
|
x-tick-step: 1,
|
||||||
|
// x-ticks: ((-1.168, [-1.16]), (1.168, [1.16])),
|
||||||
|
y-label: $cal(Q)(2, x)$,
|
||||||
|
x-label: $x$,
|
||||||
|
y-tick-step: none,
|
||||||
|
y-ticks: ((0.25, [00]), (0.5, [01]), (0.75, [10]), (1, [11])),
|
||||||
|
axis-style: "left",
|
||||||
|
x-min: -3,
|
||||||
|
x-max: 3,
|
||||||
|
y-min: 0,
|
||||||
|
y-max: 1,{
|
||||||
|
plot.add(((-3,0.25), (-1.168,0.25), (-1.168,0.5), (0, 0.5), (0, 0.75), (1.168,0.75), (1.168, 1), (3, 1)), style: line_style)
|
||||||
|
plot.add(((-2.657, 0), (-2.657, 1)), style: (stroke: (paint: red)), label: [Artificial quantizer bounds])
|
||||||
|
plot.add(((2.657, 0), (2.657, 1)), style: (stroke: (paint: red)))
|
||||||
|
plot.add-hline(0.25, 0.5, 0.75, 1, style: dashed)
|
||||||
|
plot.add-vline(-1.168, 1.168, style: dashed)
|
||||||
|
plot.add-anchor("uc01", (-0.584, 0.5))
|
||||||
|
plot.add-anchor("lc01", (-0.584, 0))
|
||||||
|
plot.add-anchor("uc10", (0.584, 0.75))
|
||||||
|
plot.add-anchor("lc10", (0.584, 0))
|
||||||
|
|
||||||
|
plot.add-anchor("uc00", (-1.9125, 0.25))
|
||||||
|
plot.add-anchor("lc00", (-1.9125, 0))
|
||||||
|
plot.add-anchor("uc11", (1.9125, 1))
|
||||||
|
plot.add-anchor("lc11", (1.9125, 0))
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
draw.line("plot.uc01", ((), "|-", "plot.lc01"), mark: (end: ">"))
|
||||||
|
draw.line("plot.uc10", ((), "|-", "plot.lc10"), mark: (end: ">"))
|
||||||
|
draw.line("plot.uc00", ((), "|-", "plot.lc00"), mark: (end: ">"))
|
||||||
|
draw.line("plot.uc11", ((), "|-", "plot.lc11"), mark: (end: ">"))
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
BIN
main.pdf
BIN
main.pdf
Binary file not shown.
16
pseudocode/bach_1.typ
Normal file
16
pseudocode/bach_1.typ
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#import "@preview/lovelace:0.3.0": *
|
||||||
|
|
||||||
|
|
||||||
|
#pseudocode-list(booktabs: true, numbered-title: [Center Point Approximation])[
|
||||||
|
+ *input*: $bold(cal(o))_"first", bold(x), t, M$
|
||||||
|
+ *lists*: optimal weights $bold(h)_"opt"$
|
||||||
|
+ $bold(cal(o)) arrow.l bold(cal(o))_"first"$
|
||||||
|
+ *repeat* t times:
|
||||||
|
+ *perform* @alg:best_appr for all input values with $bold(cal(o))$:
|
||||||
|
+ *update* $bold(h)_"opt"$ with returned weights
|
||||||
|
+ $bold(z)_"opt" arrow.l$ all returned linear combinations
|
||||||
|
+ *sort* $bold(z)_"opt"$ in ascending order
|
||||||
|
+ *define* new quantizer $cal(Q)^*$ using the @ecdf based on $bold(z)_"opt"$
|
||||||
|
+ *update* $bold(cal(o))$ with newly found quantizer step centers
|
||||||
|
+ *return* $bold(h)_"opt"$
|
||||||
|
]
|
||||||
12
pseudocode/bach_find_best_appr.typ
Normal file
12
pseudocode/bach_find_best_appr.typ
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#import "@preview/lovelace:0.3.0": *
|
||||||
|
|
||||||
|
#pseudocode-list(booktabs: true, numbered-title: [Find best approximation])[
|
||||||
|
+ *inputs*:
|
||||||
|
+ $bold(y)$ input values for linear combinations
|
||||||
|
+ $bold(cal(o))$ list of optimal points
|
||||||
|
+ *output*: $(bold(h), z_"opt")$
|
||||||
|
//+ n number of summands in linear combination
|
||||||
|
+ *calculate* all possible linear combinations $bold(z)$ with @eq:z_eq
|
||||||
|
+ *calculate* matrix $bold(cal(A))$ with $a_"ij" = abs(z_i - cal(o)_j)$
|
||||||
|
+ *return* weights $bold(h)$ for $z_"opt" = op("argmin")(bold(cal(A)))$ and $z_"opt"$
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue