Andrew Burks

Aggregated Football Scores and Gambling Print This Post

by aburks on Nov.10, 2012, under Personal Projects

A few months ago my roommate won $500, but he only had to enter $10 to play the game.  It was the first time he played, and so naturally all of the regulars were very upset.  The game works like this: A 10×10 table is set up, with each row and each column corresponding to a digit 0-9.  These digits represent the final digit in the score of the home team and the away team.  One quarter of the money goes to the person who bought the square at the intersection of the last digits of the two team’s scores in the first half.  Another quarter is paid out based on points only scored in the second half.  The final half of the money goes to the person whose name was in the box which corresponds to the last digits of the final scores of the two teams.

Blank Chart

Example Scorecard

If football scores were random, you could pick any box, cross your fingers, and have an expected payout of exactly 1 (no taxes or rake).  But scores aren’t random.  They are only added in discrete amount of 2, 3, 6, 7, and 8.  Some boxes had to be better than others, and I needed to find out exactly how much better they can be.

By using the statistics at http://www.pro-football-reference.com and a combination of PERL scripts and Excel, I was able to come up with some neat conclusions.  The data I used was from every pro game (including playoffs) from the 1974 season through November 10th, 2012.  This is a huge dataset that includes over 18,000 final scores.

First I looked at overall scores.  I was expecting to see some scores happen more frequently than others, but I was surprised at how extreme the effect was.

Frequency Chart - Final Score

The highest peak is a score of 17, which is seen in almost 8% of final scores.  Nearby peaks are 10, 20, and 24, all at about 6.5%.  The double peak of 13 and 14 is also not a surprise.  But I still hadn’t answered my question.  I didn’t need to know about the final score, just the last digit of the final score.  So I ran the same analysis across all 18,000 final scores to get a similar chart.

Frequency Chart - Last Digit

If the final digit were random you would expect the results to all be hovering around 10%.  Obviously there is something else going on here because you can see the same oscillations from the first chart again in this chart.  It appears that 0, 3, 4 and 7 occur more frequently than you would expect, and might give you an edge when you are betting.  But how much of an edge?  It gets more complicated when you combine a great number, like 7, with an average number, like 6.  Is it still worth it?  How worth it?  To answer these questions I compiled a cheat sheet showing the expected return on investment for each of the 100 positions on the chart (note that the chart is mirrored across the diagonal because it shouldn’t matter which team is which).

Payoff Chart

So now we know that betting on 7 and 7 is the best one to choose, and betting on 2 and 2 is a good way to throw away your money.  But in this game you can place multiple bets on the same board.  How does that change the betting strategy?  If you rank each box by expected value and keep betting on more and more boxes then you should expected your probability of winning to rise while your expected value shrinks, until they both equal one (when you bet on every square and win all of your own money back).  This last chart illustrates the entire betting spectrum.

Probability and Expected Value

When making this chart I was also able to demonstrate (accidentally) the error in computing experienced when multiplying together 100 different numbers that are all very near – but below – one.  Both curves should be approaching 1 or 100% as the number of bets approaches 100.  However truncation/rounding error causes both curves to miss their final target (both the probability of winning and the expected value are reported too low in all cases).  Because of the way I calculated the probabilities, I would expect the accuracy to decrease as the number of bets placed increases.  A linear scaling (probably not the right way to take the errors into account) of the previous chart results in a different chart.

Probability and Expected Value - Scaled

Leave a Comment :, , , , more...

Experimental Brake Pedal Print This Post

by aburks on Aug.08, 2010, under Formula SAE

Design

This summer I have had access to the waterjet at NREC where I had my internship.  The current pedal design calls for a series of 2-dimensional parts that I knew I could cut on the waterjet very easily (it can cut through stuff faster than 10 inches/minute, so it’s preferable to a CNC for this application).  Unfortunately I put off cutting these parts until the last week of my internship.  At 10PM on the last Tuesday night of the summer, I realized that I needed to prepare the .dxf files (files that define the shapes of a 2-dimensional part) I would need to cut some parts out after work.

When I went to make the .dxf files, I realized that I could make the entire pedal assembly out of welded steel plates cut from the waterjet.  That night I started making a new version of the pedals (version 9) and had the rough outlines of all of the key parts by the time I went to bed at 3AM.  I also never made the .dxf files I wanted for the next day.

Wednesday night I made the .dxf files I needed for the old pedal design, then spent the rest of the night optimizing the brake pedal assembly for weight.  Here are some renders of the design, as well as some FEA results:

Render - ISO Render - Front Render - Side
Stress Plot
FEA - Stress
Factor of Safety Plot
FEA - FOS

An Exploded View Animation of the Assembly Process

Fabrication

On Thursday night I stayed after work to cut my parts on the waterjet off-hours.  It took about 5 hours to cut three sets of parts for the old design and two sets of the experimental pedal.  Though the brake pedal hasn’t been welded yet, the tabs were easy to press together to get a good sense of what it will look like in real life.  I was really impressed that I could go from concept to completion in only 48 hours, thanks to SolidWorks, NREC, and the waterjet.  Mike was kind enough to take some glamour shots of the final product:

PIC - ISO

PIC - Front PIC - Right
Leave a Comment :, , , , , , , more...

Stepper Motor Driver – NAND Gates Print This Post

by aburks on Jul.11, 2010, under RobOrchestra, Robotics Club

The Problem

I still need to find a cost effective way of turning a bipolar stepper motor on and off using just one pin.  I want to have the ability to use a powered brake, and I want to be able to use half-stepping control of the motor for smoother rotation.

Half-stepping gives the motor higher resolution, which is good for my application because one full step cycle is enough to move a single ball through.  The 4-stage process from before turns into an 8-stage process when you change to half-stepping.

t=0  A=1  B=0  C=0  D=0

t=1  A=1  B=1  C=0  D=0

t=2  A=0  B=1  C=0  D=0

t=3  A=0  B=1  C=1  D=0

t=4  A=0  B=0  C=1  D=0

t=5  A=0  B=0  C=1  D=1

t=6  A=0  B=0  C=0  D=1

t=7  A=1  B=0  C=0  D=1

t=8=0

The Solution

I noticed that in half stepping (and full stepping) if you view the logic for each of the four wires as a wave, they are always 90 degrees out of phase and have a specific shape.  I wanted to create four unique signal lines, one for each of the four wave patterns, and transmit this signal to each of the 30 stepper controllers.  At each controller, I should be able to choose either some default value (like a powered or unpowered brake) or let the motor run off the signal.

Because my focus was centered on the powered brake, my initial idea was to take my on-off line at each motor and perform a logical AND with three of the four waves and a logical OR with the other wave.  The OR would drive its input high while the AND would drive its inputs low.  This solved my problem, but unfortunately I couldn’t find a chip with an AND and an OR circuit on it.

You can build any logic gate with a combination of NAND or NOR gates.  It takes two NAND gates to build an AND gate, and three NAND gates to build an OR gate (and vice-versa when building from NOR gates).  They sell IC’s with 4 NAND gates in them, so I really wanted to find a way to do my OR operation with only 2 NAND gates.

Eventually I realized that if I negated the signal wave coming from the Arduino (by using 1 NAND as an inverter) and then performed a NAND operation with the wave signal and the on-off signal I got the exact output I wanted!  of course, if I had just used an AND on each of the four inputs, I would have an unpowered brake and less of a headache.

I made this circuit on a protoboard, and tested it with both full and half stepping.  It worked like a charm.  The next step is to see if half-stepping combined with a smaller diameter wheel will be able to push balls along without jamming.  Here is the protoboard layout:

Pros

This setup allows for full and half stepping.  It costs less than the shift register design, about $2 per unit (only $0.75 from the two NAND ICs).  Each of the four inputs is completely isolated from the others, so the wiring is simpler (which makes the PCB layout easier).

Cons

There are now 4 common signal wires instead of just one.  These 4 wires will need to be jumped from board to board, potentially requiring some sort of transistor to keep the voltage from dropping as it moves across the boards.

More Photos

Leave a Comment :, , , , , , , more...

Stepper Motor Driver – Shift Register Print This Post

by aburks on Jul.06, 2010, under RobOrchestra, Robotics Club

The Problem

I need to be able to turn 30 identical stepper motors on and off individually.  I can only afford to have one unique wire going to each stepper unit because I only have ~40 digital outputs to work with.  I can afford to have a few common outputs that are jumped from board to board.  basically I need to turn four inputs that go in a pattern into one input.

The four lines on the motor driver (H-Bridge) basically take turns going high when I want the motor to turn.  When I want it to stand still, only one of the lines should be high.  This is called “wave driving” a stepper motor.  Here is what happens when a bipolar stepper motor is wave driven.

t=0:  A=1  B=0  C=0  D=0

t=1:  A=0  B=1  C=0  D=0

t=2:  A=0  B=0  C=1  D=0

t=3:  A=0  B=0  C=0  D=1

t=4=0

The Solution

A Serial in Parallel out (SIPO) Shift Register does basically exactly what I’m looking for.  If I have one common clock (a line that goes high every 1/4 step) and connect the 4th output to the data input, then the four parallel outputs will shift through my 4 states like a champ.  The only catch is that I need to seed the circuit with the initial “1″ so that the “1″ can move along the shift register.

Luckily, because a shift register is just 4 flip-flops lined up in a row, I could build my own shift register out of flip flops, and access the set/reset abilities of the individual flip-flops.  So in the final setup, I had a single clock coming from the Arduino (pulsing at 100ms intervals) which controlled the speed of the motor, and a “stop” pin coming from the Arduino to control whether or not the motor was turning.

The “stop” pin was tied to the reset pin on the first flip-flop and the set pins on the other 3.  This means that when the “stop” pin was driven low, it would force the shift register into the “1-0-0-0″ state, and when it was released the “1″ would shift sequentially at the speed of the clock to drive the motor.  Here is a view of the protoboard layout (the center IC is the motor driver, and the other two each contain two flip-flops):

Pros

This is a huge improvement over controlling all 120 lines individually.  An Arduino mega can easily output a single clock and 30 control lines.  The cost of each circuit is about $4 in parts (three Integrated Circuits, or ICs), more if you PCB it.  It works, and it lets you do a powered brake as well.

Cons

The two IC’s with flip-flops are about $2.50 0f the total parts cost.  For this price ($2.50×30=$75) it would technically be cheaper to buy some other board that can take serial from the Arduino and control the 120 outputs.  Also, the wiring is a bit complex and uninsulated because each flip-flop’s output feeds into the next one’s input.

More Photos

Leave a Comment :, , , , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...