Oct 18, 2015 at 4:17pm UTC
I was given an assignment with four parts, and one of the parts was to generate Brownian motion. How would I go about doing this?
By the way, this is my code so far:
#include<iostream>
#include<iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
const int size = 10;
double randomgen(double min, double max) {
double range = (max - min);
double div = RAND_MAX / range;
return min + (rand() / div);
}
int main()
{
double Min, Max;
cout<< "\nWhat is the minimum value in your array? >> ";
cin >> Min;
cout<< "\nWhat is the max value in your array? >> ";
cin >> Max;
double array[size];
array[0] = 0;
for(int i=1; i<size; i++){
array[i] = array[i-1] + randomgen(Min, Max);
cout << array[i] << endl;
}
system("PAUSE");
return EXIT_SUCCESS;;
}
This code was used to an array of random numbers between min and max. I'm not sure how to go about doing Brownian motion in this code.
Last edited on Oct 18, 2015 at 4:19pm UTC
Oct 18, 2015 at 5:34pm UTC
Please use the code tags for your code. HINT: Edit your post, highlight your whole code, then select the <> icon on your right side of the post.