Created
May 26, 2020 22:17
-
-
Save CosmicPangolin/4fc98d4af588d6e83f9effe6d29c839a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math' as math; | |
void main() { | |
double volOf2DHypersphere = volumeOfHypersphere(2, 1000); | |
} | |
double volumeOfHypersphere(int dimensions, int simCount) { | |
int withinCircleCount = 0; | |
List<List<double>> pointArray = []; | |
for (int j = 0; j <= simCount; j++) { | |
List<double> vector= []; | |
for (int i = 0; i <= dimensions; i++) { | |
double numBetween0and1 = math.Random().nextDouble(); | |
vector.add(numBetween0and1); | |
} | |
pointArray.add(vector); | |
} | |
pointArray.forEach((point) { | |
bool inCircle = false; | |
// Do your test-in-circle math | |
if (!inCircle) return; | |
withinCircleCount++; | |
}); | |
//Do your compute volume math with circleCount and simCount | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment