-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefendant.java
More file actions
87 lines (69 loc) · 2.35 KB
/
Copy pathDefendant.java
File metadata and controls
87 lines (69 loc) · 2.35 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// STUDENT VERSION
// Defendant.java
// Name:
// Date:
// Adapted from Jillian Cardamon 6/6/18
/* Idea (from article): each inmate is assigned a true probability of
reoffending based on normal distribution mean and std dev from the
Ohio data - weighted avg = 21.79, std dev = 13.85 then the computer
uses those probabilities to decide whether each dot will actually
reoffend a dot with a 75% risk will on average reoffend 3/4 times no
one knows the true chance of reoffending so risk assessment tries to
estimate it normal distribution with mean set at true risk and std
dev 0.15 can use random.gauss(mu, sigma) for normal distribution
*/
import java.util.*;
public class Defendant{
private double trueRisk;
private boolean willReoffend;
private double assessmentScore;
private String riskCategory;
private boolean givenParole;
Defendant(double risk, boolean reoffend){
// constructor
trueRisk = risk;
willReoffend = reoffend;
assessmentScore = 0;
riskCategory = null;
givenParole = false;
}
public String toString(){
// toString
return "Assessment Score: " + this.assessmentScore + '\n' +
"Risk Category: " + this.riskCategory + '\n' +
"Will Reoffend: " + this.willReoffend + '\n' +
"Given Parole: " + this.givenParole;
}
// accessor methods
public double getTrueRisk(){ return trueRisk; }
public boolean willOffendAgain() { return willReoffend; }
public double getAssessmentScore() { return assessmentScore; }
public String getRiskCategory() { return riskCategory; }
public boolean isGivenParole() { return givenParole; }
// mutator methods
public void assess(double low, double med, double high){
Random r = new Random();
//assessment score based on standard dev. of .15 and mean of truerisk
assessmentScore = r.nextGaussian()*0.15 + trueRisk;
if (assessmentScore <= low) {
riskCategory = "low";
} else if(assessmentScore <= med) {
riskCategory = "med";
}else {
riskCategory = "high";
}
}
public void decideParole(){
Random r = new Random();
if(riskCategory.equals("low")) {
givenParole = true;
} else if(riskCategory.equals("high")){
givenParole = false;
} else if(r.nextDouble()<0.5) {
//50% chance of parole if in med cat
givenParole = false;
}else {
givenParole = true;
}
}
}