Skip to content

Commit f256d8f

Browse files
committed
Added that \factor can have inputs and outputs
1 parent dc5a733 commit f256d8f

6 files changed

+34
-32
lines changed

example.tex

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
\node[obs] (y) {$y$} ; %
7171
\node[latent, left=of y, yshift=0.5cm] (mu) {$\mu$} ; %
7272
\node[latent, left=of y, yshift=-0.5cm] (tau) {$\tau$} ; %
73-
\factor[left=of y] {y-factor} {$\mathcal{N}$} ;
73+
\factor[left=of y] {y-factor} {$\mathcal{N}$} {} {};
7474
\factoredge {mu,tau} {y-factor} {y} ; %
7575
}
7676
\\
@@ -87,10 +87,11 @@
8787
% Nodes
8888
\node[obs] (k) {$k$}; %
8989
\node[latent, above=2 of k] (l) {$\lambda$}; %
90-
\factor[above=0.8 of k] {k-f} {Multi} ; %
91-
\node[latent, right=of k-f] (p) {$\phi$}; %
90+
\factor[above=0.8 of k] {k-f} {Multi} {} {}; %
91+
\node[latent, right=of k-f] (paa) {$\phi$}; %
92+
%\node[latent, right=of k-f] (p) {$\phi$}; %
9293
% Connections
93-
\factoredge {p} {k-f} {k} ; %
94+
\factoredge {paa} {k-f} {k} ; %
9495
% Gate
9596
\gate {} {(k-f)(k-f-caption)} {l} ; %
9697
}

model_citation_influence.tex

+12-12
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
\\
3737
& %
3838
& %
39-
\factor {T-f1} {Multi} ; & %
39+
\factor {T-f1} {Multi} {} {}; & %
4040
& %
41-
\factor {T-f2} {below:Multi} ; & %
41+
\factor {T-f2} {below:Multi} {} {}; & %
4242
\\
4343
\node[latent] (T') {$T'$} ; & %
4444
& %
4545
\node[latent] (T) {$T$} ; & %
4646
\\
47-
\factor {W'-f} {Multi} ; & %
47+
\factor {W'-f} {Multi} {} {}; & %
4848
\node[latent] (phi) {$\phi$} ; & %
49-
\factor {W-f} {Multi} ; %
49+
\factor {W-f} {Multi} {} {}; %
5050
\\
5151
\node[obs] (W') {$W'$} ; & %
5252
& %
@@ -55,14 +55,14 @@
5555
};
5656

5757
% Remaining factors
58-
\factor[above=of T'] {T'-f} {left:Multi} ; %
59-
\factor[above=of theta] {theta-f} {left:Dir} ; %
60-
\factor[above=of C] {C-f} {left:Multi} ; %
61-
\factor[above=of S] {S-f} {left:Bern} ; %
62-
\factor[above=of gamma] {gamma-f} {left:Dir} ; %
63-
\factor[above=of lambda] {lambda-f} {left:Beta} ; %
64-
\factor[above=of psi] {psi-f} {left:Dir} ; %
65-
\factor[above=of phi] {phi-f} {left:Dir} ; %
58+
\factor[above=of T'] {T'-f} {left:Multi} {} {}; %
59+
\factor[above=of theta] {theta-f} {left:Dir} {} {}; %
60+
\factor[above=of C] {C-f} {left:Multi} {} {}; %
61+
\factor[above=of S] {S-f} {left:Bern} {} {}; %
62+
\factor[above=of gamma] {gamma-f} {left:Dir} {} {}; %
63+
\factor[above=of lambda] {lambda-f} {left:Beta} {} {}; %
64+
\factor[above=of psi] {psi-f} {left:Dir} {} {}; %
65+
\factor[above=of phi] {phi-f} {left:Dir} {} {}; %
6666

6767
% Hyperparameters
6868
\node[const, above=of theta] (atheta) {$\alpha_\theta$}; %

model_lda.tex

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525

2626
% Factors
27-
\factor[above=of X] {X-f} {Multi} ; %
28-
\factor[above=of T] {T-f} {left:Multi} ; %
29-
\factor[above=of theta] {theta-f} {left:Dir} ; %
27+
\factor[above=of X] {X-f} {Multi} {} {} ; %
28+
\factor[above=of T] {T-f} {left:Multi} {} {} ; %
29+
\factor[above=of theta] {theta-f} {left:Dir} {} {} ; %
3030

3131
% More nodes
3232
\node[latent, right=of X-f] (phi) {$\phi$}; %
3333
\node[const, above=of phi] (aphi) {$\alpha_\phi$}; %
3434

35-
\factor[above=of phi] {phi-f} {right:Dir} ; %
35+
\factor[above=of phi] {phi-f} {right:Dir} {} {} ; %
3636

3737
\factoredge {theta} {T-f} {T} ; %
3838
\factoredge {atheta} {theta-f} {theta} ; %

model_pca.tex

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
\begin{tikzpicture}
1616

1717
% Define nodes
18-
\node[obs] (y) {$y$};
18+
\node[obs] (y) {$y$};
1919
\node[latent, above=of y, xshift=-1.2cm] (w) {$\mathbf{w}$};
2020
\node[latent, above=of y, xshift=1.2cm] (x) {$\mathbf{x}$};
21-
\node[latent, right=2cm of y] (t) {$\tau$};
21+
\node[latent, right=2cm of y] (t) {$\tau$};
2222

2323
% Connect the nodes
2424
\edge {x,w,t} {y} ; %

model_pca2.tex

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@
2929
% W hyper
3030
\node[const, above=1.2 of w, xshift=-0.5cm] (mw) {$\mu_w$} ; %
3131
\node[const, above=1.2 of w, xshift=0.5cm] (aw) {$\alpha_w$} ; %
32-
\factor[above=of w] {w-f} {left:$\mathcal{N}$} ; %
32+
\factor[above=of w] {w-f} {left:$\mathcal{N}$} {} {} ; %
3333
\factoredge {mw,aw} {w-f} {w} ;
3434

3535
% X hyper
3636
\node[const, above=1.2 of x, xshift=-0.5cm] (mx) {$\mu_x$} ; %
3737
\node[const, above=1.2 of x, xshift=0.5cm] (ax) {$\alpha_x$} ; %
38-
\factor[above=of x] {x-f} {left:$\mathcal{N}$} ; %
38+
\factor[above=of x] {x-f} {left:$\mathcal{N}$} {} {} ; %
3939
\factoredge {mx,ax} {x-f} {x} ;
4040

4141
% noise
4242
\node[latent, right=3cm of y-f] (t) {$\tau$}; %
43-
\factor[above=of t] {t-f} {left:$\mathcal{G}$}; %
43+
\factor[above=of t] {t-f} {left:$\mathcal{G}$}
44+
{} {} ; %
4445
\node[const, above=of t, xshift=-0.5cm] (at) {$\alpha_\tau$} ; %
4546
\node[const, above=of t, xshift=0.5cm] (bt) {$\beta_\tau$} ; %
4647
\factoredge {at,bt} {t-f} {t} ; %

tikzlibrarybayesnet.code.tex

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
\tikzstyle{const} = [rectangle, inner sep=0pt, node distance=1]
3939
% Factor node
4040
\tikzstyle{factor} = [rectangle, fill=black,minimum size=5pt, inner
41-
sep=0pt, node distance=0.4, font=\small]
41+
sep=0pt, node distance=0.4]
4242
% Deterministic node
4343
\tikzstyle{det} = [latent, diamond]
4444

@@ -67,13 +67,12 @@
6767
% Connect all nodes #2 to all nodes #4 via all factors #3.
6868
\foreach \f in {#3} { %
6969
\foreach \x in {#2} { %
70-
\draw[-,#1] (\x) edge[-] (\f) ;%
70+
\draw[-,#1] (\x) edge[-] (\f) ; %
7171
} ;
7272
\foreach \y in {#4} { %
73-
\draw[->,#1] (\f) -- (\y) ;%
73+
\draw[->,#1] (\f) -- (\y) ; %
7474
} ;
7575
} ;
76-
%\draw[<-,#1] (#2) -- (#2-factor) edge[-] (#3) ;
7776
}
7877

7978
% \edge [options] {inputs} {outputs}
@@ -89,10 +88,11 @@
8988
% \factor [options] {name} {caption} {inputs} {outputs}
9089
\newcommand{\factor}[5][]{ %
9190
% Draw the factor node. Use alias to allow empty names.
92-
\node[factor, label={[name=#2-caption]#3}, name=#2, alias=#2-alias,
93-
#1] {} ; %
91+
\node[factor, label={[name=#2-caption]#3}, #1] (#2) {} ; %
92+
%\node[factor, label={[name=#2-caption]#3}, name=#2, #1,
93+
%alias=#2-alias] {} ; %
9494
% Connect all inputs to outputs via this factor
95-
\factoredge {#4} {#2-alias} {#5} ; %
95+
%\factoredge {#4} {#2-alias} {#5} ; %
9696
}
9797

9898
% \plate [options] {name} {fitlist} {caption}

0 commit comments

Comments
 (0)