In an earlier post I experimented with random bipartite graphs. With a little more practice under my belt, I've incorporated the same basic idea to create a random picture that is used in the latest addition to the Sagetex:Combinatorics/Probability page; problem 14. There are actually 3 problem variations here, depending on how deep you want to go into the classic problem of finding the number of shortest paths in a grid. There are several random aspects of the problem: the number of vertical lines in the grid, the number of horizontal lines in the grid, and the placement of the point M in the grid that all "special" paths must go through.

The basic idea for these problems is that your LaTeX file is a string and a part of the string will be created in sagesilent and then inserted into your latex document with a statement like \sagestr{output}. By creating the string in the sagesilent environment you're getting the power of Python and Sage commands. LaTeX was made for typesetting, so it's computational skills are limited. By tapping into Sage's calculating power combined with Python commands (for loops, strings) the sagetex package vastly increases the power of what can be accomplished in LaTeX.

The latest problem has you determine:

- the number of shortest paths from A to Z (bottom left to top right)
- the number of shortest paths from A to Z that go through M
- the probability that a randomly chosen shortest path goes through M

Here is the sagesilent code from the latest problem. Note that the blog has destroyed the indentation which is necessary in Python. You should download the template (problem 14 on Sagetex: Combinatorics/Probability) for correct formatting.

\begin{sagesilent}

k = Integer(randint(6,9))

n = Integer(randint(5,6))

m2 = Integer(randint(n-4,n-2))

m1 = Integer(randint(k-5,k-2))

output = r""

output += r"\begin{tikzpicture}[scale=.7]"

for i in range(0,n+1):

output += r"\draw (0,%s)--(%s,%s);"%(i,k,i)

for i in range(0,k+1):

output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

output += r"\draw [fill] (0,0) circle [radius=2pt];"

output += r"\node [left] at (0,0) {$A$};"

output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(k,n)

output += r"\node [right] at (%s,%s) {$Z$};"%(k,n)

output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(m1,m2)

output += r"\node [above left] at (%s,%s) {$M$};"%(m1,m2)

output += r"\end{tikzpicture}"

\end{sagesilent}

For the code above k and n are the length and width of the rectangle, so there are k+1 vertical lines and n+1 horizontal lines. Point M will have the coordinates (m1, m2). After choosing n, k, m1, and m2 randomly the picture that you would normally create in the body of your latex document is "typed" in sagesilent as a string, called output. The command: output += r"\begin{tikzpicture}[scale=.7]" starts building the string. The r occurs before the " symbol to indicate that a raw string is used. This is needed because LaTeX has various symbols, such as \, that aren't treated properly if output was a normal string. The default scale is 1, I've dropped it to .7 to make the picture smaller. This allows me you put have a bigger grid for your picture without it running out of the margins.

Python for loops create the horizontal lines

for i in range(0,k+1):

output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

and vertical lines

for i in range(0,k+1):

output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

The %s is the string content that will be filled in. In

output += r"\draw (%s,0)--(%s,%s);"%(i,i,n)

there are 3 strings that have data that needs to be determined by Python. The respective values will be i, i, and n, which are varying depending on where you are in the for loop.

The placement of points is determined through commands like

output += r"\draw [fill] (%s,%s) circle [radius=2pt];"%(m1,m2)

There are 2 strings that need to be filled. The first string is that random value m1 and the second string will be the random m2 value.

Creating random test/quiz problems save you time in creating tests, provide you with a solution, and eliminate potential mistakes. Have a student who missed your test? Create a different version quickly.

Here are some current events that caught my eye.

- As you probably know, Asia is the land of fakes. Whether it's fake Rolex watches, fake DVD's, fake designer bags, or fake Ferraris, appearances can be deceptive. You need to be alert to fake doctors, fake teachers (with fake diplomas) and fake monks. It should be no surprise that cheating is rampant in Asia; it's so "advanced" there you might call it an art form. A great example of this is the cheating scandal a couple of years ago. Lots of students tried cheating, and some teachers caught them. That led to a firestorm, "By late afternoon, the invigilators were trapped in a set of school offices, as groups of students pelted the windows with rocks. Outside, an angry mob of more than 2,000 people had gathered to vent its rage, smashing cars and chanting: "We want fairness. There is no fairness if you do not let us cheat."". So it should be no surprise to hear about the latest cheating in China. First up is the cheating on SATs in Asia. From the article: "Bob Schaeffer, public education director of the nonprofit National Center for Fair & Open Testing, known as FairTest, said that his organization had received several e-mails from sources in Asia alleging that the SAT given on Nov. 8 was circulating among students before it was administered. One message included a screen shot of what appeared to be an entire SAT exam in Chinese.". Technically, this cheating allegation hasn't been confirmed but anyone with experience in Asia knows it has to be true. In fact, the article mentions, "Many local educators believe that the test-makers did not aggressively pursue cheating claims to protect the reputation of their flagship product, the SAT.", so I suspect this will get swept under the rug. You can get more details from an earlier story.
- The Daily Mail highlights some of China's attempts to crack down on cheating in high school. From the article, "With thousands of Chinese students resorting to 007-style gadgets such as pinhole cameras and radio transmitter bras to cheat in their exams, one college decided to take a stand....
Security staff in Jinlin, Jiangsu and Guangdong provinces revealed that students started using sophisticated radio vests in order to receive help from someone outside the hall.

Pupils were also taking pictures of the tests using a button-hole camera hidden in a pen or watch, then using a copper antenna loop stitched into their clothing to beam it out of the hall to someone sitting with a receiver".

- 2440 students were caught cheating in China on a pharmacy exam. Here's a video of news coverage.
- ZeroHedge had a piece that illustrates how high school quality has dropped: the article says, "The number of college students taking at least one remedial course rose to 2.7 million in the 2011-2012 academic year from 1.04 million in 1999-2000, federal data show. During the same span, the amount of federal grants spent by undergraduates enrolled in at least one remedial course rose 380%, after inflation, Education Department figures show.
**There was also a drastic rise in remedial students taking on student debt**." - RT reports that a racist high school administrator tweet led to a student walk out.
- LA Times tells us about 6 students getting arrested after fights break out. The school had to go into lockdown. Education is not what it used to be.