Skip to content

Instantly share code, notes, and snippets.

@nz
Created May 13, 2009 17:09
Show Gist options
  • Save nz/111135 to your computer and use it in GitHub Desktop.
Save nz/111135 to your computer and use it in GitHub Desktop.
var growthFactor = function(totalTweets) {
var lowerBoundTweets = 100;
var lowerBoundGrowth = 1;
var upperBoundTweets = 200;
var upperBoundGrowth = 1.5;
var dx = upperBoundTweets - lowerBoundTweets;
var dy = upperBoundGrowth - lowerBoundGrowth;
var growth = (totalTweets - lowerBoundTweets) * (dy / dx) + lowerBoundGrowth;
if (growth < lowerBoundGrowth) return lowerBoundGrowth;
if (growth > upperBoundGrowth) return upperBoundGrowth;
return growth;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment