-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGasex.java
More file actions
24 lines (23 loc) · 801 Bytes
/
Gasex.java
File metadata and controls
24 lines (23 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.*;
import java.util.concurrent.ThreadLocalRandom;
public class Gasex{
public static void main(String[] args) throws FileNotFoundException{
PrintStream output = new PrintStream(new File ("Gas1.txt"));
int time = 0;
int N = 14400;
int nleft = N/2;
double meansum = 0;
double Nsteps = 500000;
for (int j =0; j < Nsteps;j++){
double rando = ThreadLocalRandom.current().nextInt(1, N + 1);;
if (rando < nleft) {
nleft--;
} else {
nleft++;
}
time++;
meansum += (Math.pow(nleft-N/2, 2))/Nsteps;
}
System.out.println(meansum);
}
}