Skip to content

Instantly share code, notes, and snippets.

@martynchamberlin
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martynchamberlin/0454e7fe9e80ee4386c7 to your computer and use it in GitHub Desktop.
Save martynchamberlin/0454e7fe9e80ee4386c7 to your computer and use it in GitHub Desktop.
Calculates the mathematical probability of ecological validity of a given experiment, where the Y axis is the percentage of probability and each data point in the graph is a new independent variable being introduced to the experiment. As more independent variables are introduced, the accuracy exponentially diminishes. Needless to say, you need t…
// Playground - noun: a place where people can play
import Cocoa
var i: Int = 0
func power(#x :Int, #y :Int) -> Int {
if(y == 0) {
return 1;
}
return (x * power( x:x, y:y-1) );
}
for i in 0..20
{
var j: Int = power( x:2, y:i) - 1
var k = Double(j)
100 / k // this is the line for which you'll want to view the graph
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment