Created
October 16, 2019 16:49
-
-
Save rez-f/0412a904b630f8e95fa9a187c99153a7 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
package com.rez.apps; | |
/* | |
@author | |
RRRR EEEE ZZZZZ | |
R R E Z | |
RRR EEEE Z | |
R R E Z | |
R R EEEE ZZZZZ | |
*/ | |
interface RegresiLinierSederhana{ | |
void setData_prediktor(double[] dataPrediktor); | |
void setData_response(double[] dataResponse); | |
void setNilai_sigmaX(); | |
void setNilai_sigmaY(); | |
void setNilai_sigmaXY(); | |
void setNilai_sigmaX2(); | |
void setNilai_a(); | |
void setNilai_b(); | |
void setNilai_n(double n); | |
void setNilai_X(double X); | |
double getNilai_sigmaX(); | |
double getNilai_sigmaY(); | |
double getNilai_sigmaXY(); | |
double getNilai_sigmaX2(); | |
double getNilai_n(); | |
double getNilai_Y(); | |
} | |
class estimasiJumlahMahasiswaLulus implements RegresiLinierSederhana{ | |
private double sigmaX, sigmaY, sigmaXY, sigmaX2, X, Y, a, b, n, dataPrediktor[], dataResponse[]; | |
@Override | |
public void setNilai_sigmaX() { | |
double tmp = 0; | |
for (int i = 0; i < this.dataPrediktor.length; i++){ | |
tmp += dataPrediktor[i]; | |
} | |
this.sigmaX = tmp; | |
} | |
@Override | |
public void setNilai_sigmaY() { | |
double tmp = 0; | |
for (int i = 0; i < this.dataResponse.length; i++){ | |
tmp += dataResponse[i]; | |
} | |
this.sigmaY = tmp; | |
} | |
@Override | |
public void setNilai_sigmaXY() { | |
double tmp[] = new double[dataPrediktor.length]; | |
double tmp2 = 0; | |
for (int i = 0; i < this.dataPrediktor.length; i++){ | |
tmp[i] = dataPrediktor[i] * dataResponse[i]; | |
} | |
for (int i = 0; i < this.dataPrediktor.length; i++){ | |
tmp2 += tmp[i]; | |
} | |
this.sigmaXY = tmp2; | |
} | |
@Override | |
public void setNilai_sigmaX2() { | |
double tmp[] = new double[dataPrediktor.length]; | |
double tmp2 = 0; | |
for (int i = 0; i < this.dataPrediktor.length; i++){ | |
tmp[i] += dataPrediktor[i] * dataPrediktor[i]; | |
} | |
for (int i = 0; i < this.dataPrediktor.length; i++){ | |
tmp2 = tmp2 + tmp[i]; | |
} | |
this.sigmaX2 = tmp2; | |
} | |
@Override | |
public void setNilai_a() { | |
this.a =( ( this.sigmaY * this.sigmaX2 ) - ( this.sigmaX * this.sigmaXY ) ) / ( ( this.n * this.sigmaX2 ) - ( this.sigmaX * this.sigmaX ) ); | |
} | |
@Override | |
public void setNilai_b() { | |
this.b = ( ( this.n * this.sigmaXY ) - ( this.sigmaX * this.sigmaY ) ) / ( ( this.n * this.sigmaX2 ) - ( this.sigmaX * this.sigmaX ) ); | |
} | |
@Override | |
public void setNilai_n(double n) { | |
this.n = n; | |
} | |
@Override | |
public void setNilai_X(double X) { | |
this.X = X; | |
} | |
@Override | |
public void setData_prediktor(double[] dataPrediktor) { | |
this.dataPrediktor = dataPrediktor; | |
} | |
@Override | |
public void setData_response(double[] dataResponse) { | |
this.dataResponse = dataResponse; | |
} | |
@Override | |
public double getNilai_Y() { | |
this.Y = this.a + ( this.b * this.X); | |
return Y; | |
} | |
@Override | |
public double getNilai_sigmaX() { | |
return this.sigmaX; | |
} | |
@Override | |
public double getNilai_sigmaY() { | |
return this.sigmaY; | |
} | |
@Override | |
public double getNilai_sigmaXY() { | |
return this.sigmaXY; | |
} | |
@Override | |
public double getNilai_sigmaX2() { | |
return this.sigmaX2; | |
} | |
@Override | |
public double getNilai_n() { | |
return n; | |
} | |
protected int jumlahKelulusanMahasiswa(){ | |
return (int) this.getNilai_Y(); | |
} | |
} | |
public class Kelompok_3 { | |
static int tahun = 2019; | |
public static void main(String[] args) { | |
double[] dataPrediktor = { | |
1299,1208,1286,1352,1330,1337,1346,1328,1491,1424,1504,1544,1571,1598,1612 // Merupakan data jumlah mahasiswa masuk 15 tahun terakhir | |
}; | |
double[] dataResponse = { | |
869,997,1059,1080,1017,1044,1056,1165,1255,1126,1139,1179,1188,1204,1378 // Merupakan data jumlah mahasiswa lulus 15 tahun terakhir | |
}; | |
int[] dataEstimasiMahasiswaMasuk = { | |
1690,1521,1721,1782,1683 // Merupakan data Estimasi jumlah mahasiswa masuk 5 tahun yang akan datang. 2019 - 2023. | |
}; | |
if (dataPrediktor.length != dataResponse.length){ | |
System.out.println("Estimasi tidak dapat dijalankan, mohon periksa kembali data anda"); // Jika jumlah data Prediktor dan Response tidak sama, estimasi tidak dijalankan | |
}else{ | |
estimasiJumlahMahasiswaLulus tugas5 = new estimasiJumlahMahasiswaLulus(); | |
tugas5.setData_prediktor(dataPrediktor); | |
tugas5.setData_response(dataResponse); | |
tugas5.setNilai_n(dataPrediktor.length); | |
tugas5.setNilai_sigmaX(); | |
tugas5.setNilai_sigmaY(); | |
tugas5.setNilai_sigmaXY(); | |
tugas5.setNilai_sigmaX2(); | |
tugas5.setNilai_a(); | |
tugas5.setNilai_b(); | |
for (int i = 0; i < dataEstimasiMahasiswaMasuk.length; i++){ | |
int tmp = tahun+i; | |
tugas5.setNilai_X(dataEstimasiMahasiswaMasuk[i]); | |
System.out.println("Estimasi Jumlah Mahasiswa Lulus Tahun "+ tmp +" berjumlah "+ tugas5.jumlahKelulusanMahasiswa() + " Mahasiswa "); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment