Blame view

src/mior/model/dist/LinearDistribution.java 514 Bytes
89f70c1ec   glaville   import current mc...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  package mior.model.dist;
  
  import java.util.Random;
  
  public class LinearDistribution extends AbstractMiorDistribution {
  	
  	private final double variation;
  	private final Random rng;
  	
  	public LinearDistribution(int meanMM, int meanOM, double variation) {
  		super(meanMM, meanOM);
  		this.variation = variation;
  		this.rng = new Random();
  	}
  	
  	@Override
  	public double getFactor() {
  		return 1 + (2 * rng.nextFloat() - 1) * variation;
  	}
  	
  	@Override
  	public double getMaxFactor() {
  		return 1.0 + variation;
  	}
  	
  }