How to visualize Viterbi path in Latex or Graphviz - graphics

I'm looking for a way to visualize a Viterbi path in LaTeX or maybe Graphviz, much like in this example:
It doesn't have to be dots, but it could also be actual values between the lines. Much like a table with lines between cells.
I tried searching for ways to do this, but most likely I'm not using the right keywords.

Here's one way to achieve this using graphviz with invisible edges:
graph {
splines=false;
nodesep=0.5;
ranksep=0.5;
node[shape=point, height=0.08];
{ rank=same; a1 -- b1 -- c1 -- d1 -- e1;}
{ rank=same; a2 -- b2; b2 -- c2[style=invis]; c2 -- d2; d2 -- e2[style=invis];}
{ rank=same; a3 -- b3[style=invis]; b3 -- c3; c3 -- d3[style=invis]; d3 -- e3;}
edge[style=invis];
a1 -- a2 -- a3;
b1 -- b2 -- b3;
c1 -- c2 -- c3;
d1 -- d2 -- d3;
e1 -- e2 -- e3;
edge[style=solid, constraint=false];
a2 -- b3 -- c2 -- d3 -- e2;
}

Related

Solving simultaneous equations in excel

I have 4 equations, with 4 unknowns, a,b,c,e
w = c + 0.43*a
x + gb = pc + 2*e
y + 2a + hb = qc + 20.43a + e
z + bi = cr
What would be the best way to solve this in Excel?
I searched and found that LINEST might be a good function to use, but couldn't get it to work
Thanks
First rewrite all you formulas in the form
Ai*(a)+Bi*(b)+Ci*(c)+Ei*(e)=Ki
Then for each equation fill out a row in the matrix
A1 B1 C1 E1 a K1
A2 B2 C2 E2 x b = K2
A3 B3 C3 E3 c K3
A4 B4 C4 E4 e K4
Then use MInverse and MMultiply functions to solve for a,b,c and e
A,B,C,E are the constants multiplying each variable. Set them to 0 when they are not in the formula, and make sure you carry the negative sign.
i is just a way to represent the equation number.
K is the constant in the equation with out a variable attached to it.
So provided I did the formula rearrangement properly, one possible result would be:
Cant take it farther than this as numbers would be needed for g, p, h, q, i, and r (not to mention w, x, y, and z). Though you could set those up in cells so you sheet would automatically update when you entered values.

PlantUML: how to sort items? ... and grouping

I am not sure about how to sort components in PlantUML.
From this code:
#startuml
package "TEMP" {
component [A 1] as A1
component [A 2] as A2
component [A 3] as A3
component [A 4] as A4
component [A 5] as A5
component [A 6] as A6
A1 -[hidden]- A4
A2 -[hidden]- A5
A3 -[hidden]- A6
}
#enduml
I get:
A3 A2 A1
A6 A5 A4
If I flip A3, A2 and A1 only, I get:
A1 A2 A3
A4 A5 A6
i.e., also A6, A5 and A4 are flipped.
Is this normal behavior?
Is PlantUML normal behavior to flip the order of the components, so that I have to invert them?
Below, I use the -[hidden]- token to group the objects as I want. Is this the correct approach?
Well, just leave it as
package "TEMP" {
component [A 1] as A1
component [A 2] as A2
component [A 3] as A3
component [A 4] as A4
component [A 5] as A5
component [A 6] as A6
}
or specify relative positions for all
package "TEMP" {
component [A 1] as A1
component [A 2] as A2
component [A 3] as A3
component [A 4] as A4
component [A 5] as A5
component [A 6] as A6
A1 -[hidden]> A2
A2 -[hidden]> A3
A1 -[hidden]-> A4
A2 -[hidden]-> A5
A3 -[hidden]-> A6
}
Both generate the same

pyspark - Read files with custom delimiter to RDD?

I am newbie in pyspark, and I'm trying to read and merge RDD rows into one row.
Assuming that I have the following text file:
A1 B1 C1
A2 B2 C2 D3
A3 X1 YY1
DELIMITER_ROW
Z1 B1 C1 Z4
X2 V2 XC2 D3
DELIMITER_ROW
T1 R1
M2 MB2 NC2
S3 BB1
AQ3 Q1 P1"
Now, I want to combine all rows appears in each section (between DELIMITER_ROW) into one row, and return a list of these merged rows.
I want to create this kind of list:
[[A1 B1 C1 A2 B2 C2 D3 A3 X1 YY1]
[Z1 B1 C1 Z4 X2 V2 XC2 D3]
[T1 R1 M2 MB2 NC2 S3 BB1 AQ3 Q1 P1]]
How can It be done in pyspark using RDD?
For now I know how to read the file and filter out the delimiter rows:
sc.textFile(pathToFile).filter(lambda line: DELIMITER_ROW not in line).collect()
but I don't know how to reduce/merge/combine/group the rows in each section into one row.
Thanks.
Rather than reading and splitting, You can use hadoopConfiguration.set to set the delimiter which separates the row and then split the row.
spark.sparkContext.hadoopConfiguration.set("textinputformat.record.delimiter", "DELIMITER_ROW")
Hope this helps!

Dynamic input from cells

I need to do the following, (I will use an example to make it simpler)
Let's assume that cell's A1 value is 10, and represents number of coin flips.
Then I want in column B to have 10 cells waiting for the result of each coin flip.
B1 = "Coin Flip 1", B2 = "Coin Flip 2" ... B10 = "Coin Flip 10"
But if I change A1 from 10 to any other number I want column B to change correspondingly, (i.e. if A1 = 5 I want B1 = "Coin Flip 1", ..., B5 = "Coin Flip 5" )
I am sure that this has been asked again, but I couldn't find it.
Thanks in advance.
Put this in B1 and copy down as many rows as you will ever want to display, or just fill the entire column with it:
=IF(ROW()<=$A$1,"Coin Flip " & ROW(),"")

What will be the circuit for the counter with oscillating 1s (1000, 0100, 0010, 0001, 0010, 0100)?

I have a basic understanding of custom counter.
I know of a method to implement (8,4,2,1,2,4) counter i.e. using FSM, but I am not able to figure out how the circuit will get implemented?
This is at best marginally to do with programming but it may be better on one of the other sites where you'll no doubt get a better answer than this one.
However, in terms of an actual answer (whatever its shortcomings), this is difficult to do because each state does not wholly dictate the following state. By that, I mean there is no way to tell whether the pattern 0010 should be followed by 0100 (going left) or 0001 (going right).
However, there is a way to do this with a six-bit rotating shift register (a) as follows:
b5 b4 b3 b2 b1 b0
+-> 1 0 0 0 0 0 --+
| |
+-----------------------+
Then, you combine the bits to generate actual result bits:
b5 -> r3
b4 OR b0 -> r2
b3 OR b1 -> r1
b0 -> r0
That way you see the repeated pattern:
b5 b4 b3 b2 b1 b0 | b5 b4 ...
r3 r2 r1 r0 r1 r2 | r3 r2 ...
And, if you want some delay at the ends, you simply use an eight-bit shift register with slightly different combining. such that it lingers for twice as long on r3 and r0:
b7 OR b0 -> r3
b6 OR b1 -> r2
b5 OR b2 -> r1
b4 OR b3 -> r0
This gives:
b7 b6 b5 b4 b3 b2 b1 b0 | b7 b6 ...
r3 r2 r1 r0 r0 r1 r2 r3 | r3 r2 ...
(a) Although that link seems to specify non-rotating shift registers, it should be a simple matter to create a rotating one just by feeding the output of the rightmost bit back into the leftmost one.

Resources