Archive for the 'ajax' Category

Calculating the value of a single lottery ticket

Here’s a neat question – how much is a lottery ticket worth before the numbers are drawn?

The problem is a fun one for someone with a love of statistics, or someone who just wants to prove a point about why they never buy a lottery ticket. To answer it, I first make a few assumptions.

  1. The value of a future dollar is uncertain, so I will only base the value of winning a jackpot on the cash payment option, and not the annuity payments.
  2. Any prize over $5000 will automatically be taxed at a rate of 25% to federal and possibly some additional amount to state and local depending on the winner’s location. Hence, a jackpot-winning ticket is only worth at most 75% of the cash payment option after taxes.
  3. The more tickets that are purchased, the more likely it is that the jackpot will be shared if won, and so the number of tickets purchased must be a factor in any value equation.
  4. The non-jackpot prizes, since they cannot be shared and do not increase from drawing to drawing, will reduce to a simple constant in terms of the theoretical value of a ticket. (not actually true in California for some reason, so CA residents shouldn’t rely on this calculator too much)

To calculate the constant value of the non-jackpot prizes, I can use the odds and prizes printed right on the website of the lottery commission and add the resultant values of each together. For instance, a 1 in 50 chance of winning two dollars confers a pre-drawing value of 4 cents onto a random ticket.

The math is complicated, so I won’t post it all here, but if you’re interested you can read about it over at my personal blog.

Since the calculator involves knowing the number of tickets in play, I’ve worked out a formula for guesstimating the number of tickets sold for a Mega Millions or a Powerball drawing based on the going jackpot. To see it in action, fill in the cash prize amount and then click the appropriate setup link (or leave it blank and the current numbers will fill in for you automatically). I derived the formula using Excel’s trendline function. I’m actually pretty happy with my result. The R-squared value on what turned out to be a classic-looking quadratic was .9955 for Mega Millions and .9875 for Powerball, which is more than suitable for our purposes.

To quickly populate the settings for one of the two big US multi-state drawings, click one of the options below:
Set form for Mega Millions
Set form for Powerball

Jackpot Cash (not annuity) Value: $ million
State and Local Taxes:
(federal taxes automatically fixed at 25%)
%
Number of Tickets in Play: million
Jackpot Odds of Winning: 1: million
Other Prizes, Odds

Hypothetical value of 1 random lottery ticket:

April 02 2008 | ajax | 3 Comments »

A more general approach to the ISR interview widget

Recently, I developed a WordPress plugin for the company I work for, Inside Success Productions. It gave WordPress users the ability to easily add a feed from our website to their blogs, and for our affiliates this meant the chance to earn a small passive income for every new subscriber they sent our way.

Now the problem is, this only works with WordPress, and there are many other ways of distributing content on the net. So today I created a generalized method to add the same content as the plugin, but which works with any type of webpage. If it can show adsense, it can show our feed. Admittedly, we can’t get SEO benefit from it, since the links are generated with javascript. But just getting out there and being syndicated by our affiliates is still sufficient motivation for doing it. And also, it gave me a chance to apply a little more of my recently acquired AJAX skill (that’s the bit that lets the form tell people how many potential interviews their preferences match).

Play around with it below. Just remember, if you want to earn affiliate commissions, first you’ll have to become a gold member and then fill out our application to become an affiliate.

The preview to the left was created with the following code embedded in my post:

<script src=”http://www.insidesuccessradio.com/tools/ widget_feed.php?output=js&afid=405203&size=1&shows= &cats=&keywords=” type=”text/javascript”></script>

Try it out for yourself by using our script generator:

Enter your ISR affiliate ID:
Select your preferred categories:…or check this box to accept interviews from all categories
Select your preferred shows in the ISR network:…or check this box to accept interviews from all shows
Select your preferred keywords
(or select no keywords to match more interviews)

Keywords or Key Phrases
Select Your preferred display size

(Copy and Paste the following code into any webpage)


October 18 2007 | ajax | Comments Off on A more general approach to the ISR interview widget

My First AJAX project

One of the things which I feel has held back some of my web applications from their true potential has been my lack of javascript knowledge, and AJAX methods especially. I finally decided to do something about this, so I bought a book “AJAX and PHP” from Amazon last week. It arrived this past Friday and I’ve been having a blast learning this technology.

Happily, AJAX isn’t anything technically “new” it’s just a way of using 2 languages that I already have a grasp of. After playing with the examples in the book, I decided to get my feet wet by converting one of my old scripts into AJAX in order to improve its speed.

Basically, this was a component of EdocWizard (mentioned here) which allowed people to select the appropriate subjects for their eDocs. The subjects are all based on what are called BISAC codes, which simply stands for Book Industry Standards And Communications. The official list of codes can be found at the Book Industry Study Group’s website. I have them backed up to my database, and there’s currently just over 3000 different codes recognized. Amazon allows publishers to pick up to 4 subject codes for each eDoc.

These subject codes are broken up into categories, and originally, I simply made the user wait while the entire 3000+ codes were copied from the database into javascript arrays, and then I had functions that could switch out the display to show the appropriate subjects based on the category the user had selected. My intent was to make it fast to switch between categories without forcing a page reload. It worked, but depending on connection speed it could take a long time for the complete page to finish loading. In retrospect, I should’ve simply forced a page refresh.

Anyway, none of that matters now that the tool has been converted to use AJAX. Check it out by using the form below.

October 08 2007 | ajax and php projects | Comments Off on My First AJAX project