/ *
* To change this license header choose License Headers in Project Properties .
* To change this template file choose Tools | Templates
* and open the template in the editor .
* /
package refining_java;
import java . lang . annotation . Documented;
import java . ] lang . annotation . ElementType;
import java . lang . annotation . Retention; [19659007] import java . lang . annotation . RetentionPolicy;
import java . lang . annotation . Target;
import javax . swing . JOptionPane;
/ * * [19659002] * Created on Friday, December 28, 2018
*
*
* /
@Rafael_Angel_Montero_Fernandez
public class RegrecionLineal {
public Model model = new Model () ;
public double linear_region ( double next_time ) {
this . sumatoria_t () ;
this . sumatoria_x () ;
this . sumatoria_t_elevado_al_quadrado () ;
this . ] sumatoria_x_por_t () ;
this . total_t_elevado_al_quadrado () ;
this . average_of_t () ;
this . average_of_x () ;
this . slope_b () ;
this . intersection_A () ;
model . setProximo_t ( next_time ) ;
model . setXt ( model . getInterseccion_A ([19659024]) + ( model . getPendiente_B () * model . getProximo_t () ) ) ;
model . msjResults () ;
return model . getRegrecion_lineal () ;
}
public double regrecion_lineal ( double mTime [ ]] double mValores [[19659024]] double next_time ) {
model . mTtiempo_t = mTime;
model . mValores_x = mValores;
this . sumatoria_t () ;
this . sumatoria_x () ;
this . sumatoria_t_elevado_al_quadrado () ;
this . sumatoria_x_por_t ( ) ;
this . total_t_elevado_al_quadrado () ;
this . average_of_t ( ]) ;
this . average_of_x () ;
this . pending_b () ;
this . intersection_A () ;
model . setProximo_t ( next_time ) ; [19659007] model . setXt ( model . getInterseccion_A () + ( model getPendiente_B () * model . getProximo_t () ) ) ; [19659007] model . msjResults () ;
return model . getRegrecion_lineal () ;
] }
private void intersection_A () {
model . setInterseccion_A ( model . getPromedio_de_x () - [1 9659024] ( model . getPendiente_B () * model . getPromedio_de_t () ) ) ;
}
private void pending_b () {
double operacion1 = model . mTtiempo_t . length * model . getSumatoria_t_por_x () ;
System . out . println ( "operacion1 = " + operacion1 ) ;
double operation = model . getSumatoria_de_x () * model . getSumatoria_t ([19659024]) ;
System . out println ( "operation2 = " + operation2 ) ;
double operation3 = ] model . mTtiempo_t . length * model . getSumatoria_t_elevado_al_cuadrado () ;
System . out . println ( "operacion3 = " + operacion3 ) ; [19659007] double operation = operation - operation
System . out . println ( "operation4 = " + operation4 ) ;
double operation5 = operation3 - model . getT_elevado_al_cuadrado () ; [19659007] model . setPendiente_B ( operation4 / operation5 ) ;
System . out . println (
"operacion5 = " + operacion5 ) ;
}
private void media_de_t ] () {
model . setPromedio_de_t ( model . getSumatoria_t () / 6 ) ;
}
private void average_of_x () {
model . setPromedio_de_x ( model . getSumatoria_de_x () / 6 ) ;
}
private void total_t_elevado_al_quadrado () {
model . setT_elevado_al_cuadrado ( Math . pow ( model . getSumatoria_t ] () 2 ) ) ;
System . out . println ( "model . getT_elevado_al_cuadrado () = " + model . getT_elevado_al_cuadrado ([19659024]) ) ;
}
private void sumatoria_t_elevado_al_quadrado () {
int i = ] 0;
while ( i < = model . mValores_x . length - 1 ) {
model . setSumatori a_t_elevado_al_quadrado ( model . getSumatoria_t_elevado_al_quadrado () + Math . pow ( model . mTtime_t [ i ] 2 ) ) ;
i + + ;
}
}
private void sumatoria_t () {
int i = 0;
while ( i < = model . mValores_x . length - 1 ) {
model . setSumatoria_t ( model . getSumatoria_t () + model . mTtiempo_t [ i ] ) ;
+ + ;
}
}
private void sumatoria_x () {
int i = 0;
while ( i < = model . mValores_x . length - 1 ) {
model . setSumatoria_de_x ( model . ] getSumatoria_de_x () + model . mValores_x [ i ] ) ;
i + + ;
}
}
private void sumatoria_x_por_t () {
int i = 0;
while ( i <[1 9659016] = model . mValores_x . length - 1 ) {
model . setSumatoria_t_por_x ( model . getSumatoria_t_por_x () + ( model . mValores_x [ i ] * model . mTtiempo_t [ i ] ) ) ;
System . out . println ( "model . getSumatoria_t_por_x () = " + model . getSumatoria_t_por_x () ) ;
i + + ;
] }
System . out . println ( ] "model . getSumatoria_t_por_x () = " + model . getSumatoria_t_por_x ( ) ) ;
}
public static void main ( String args [] ) {
RegrecionLineal regresion_l = new RegreLineal () ;
regresion_l . model . setValores_de_x ( "7000 9000 5000 11000 10000 13000" ) ;
regresion_l . model . setTiempos ( "1 2 3 4 5 6" ) ;
final double next_t = 7; // Original 7
JOptionPane . showMessageDialog ( null Math . round ( regresion_l . ] linear_region ( next_t ) ) "Linear Regression from the main" JOptionPane . INFORMATION_MESSAGE ]) ;
}
public class Model {
public double mValores_x [] = {} ;
/ * *
*
* @param new_values_of_x You must pass the numeric values in String format and spaced by spaces .
* Example setValores_de_x ( "100 20 35 41 55 67 7000" ) .
* /
public void setValues_of_x ( String new_values_of_x ) {
int i = 0;
String mValues [] = new_values_of_x . split ( "" ) ;
this . mValores_x = new double [ mValues . length ] ;
while ( i < = ] mValues . length - 1 ) {
mValores_x [ i ] = Double . parseDouble ( mValues [ i ] ) ;
i + + ];
}
} [19659006]
private double mTtiempo_t [] = {} ;
/ * *
*
* @param new_time You must pass the numeric values in String format and spaced by spaces .
* Example setTimes ( "1 2 3 4 5 6 7" ) .
* /
public void setTimes ( String new_time ) {
int i = 0;
String mTimes [] = new_time . split ( "" ) ;
this . mTtiempo_t = new double [ mTimes . length ] ;
while ( i < = ] mTimes . length - 1 ) {
] mTtiempo_t [ i ] = Double . parseDouble ( mTimes [ i ] ) ;
i + + ];
}
}
[19659007] public double proximo_t = 0 . 0;
public Model ( double new_mTime [] , double new_mValues_x [] double next_time ) {
mValores_x = new_mValores_x;
mTtiempo_t ] = new_mTime;
this . setProximo_t ( next_t ) ;
}
public Model ( double new_x_por_t double new_summary_of_x double new_summary_t_by_x double new_t_elevado_al_quadrado double new_summary_t_elevado_al_quadrado double new_summary_t double new_pendiente_B ] double new_promedio_de_t double new_promedio_de_x double new_xt ) {
setX_por_t ( new_x_por_t ) ; [19659007] setSummary_of_x ( new_summary_of_x ) ;
setSumatoria_t_por_x ( new_summary_t_by_x ) ;
setT_elevado_al_cuadrado ( nuevo_t_elevado_al_cuadrado ) ; [19659007] setSumatoria_t_elevado_al_cuadrado ( nuevo_sumatoria_t_elevado_al_cuadrado ) ; [19659007] setSumatoria_t ( nuevo_sumatoria_t ) ; [19659007] setPendiente_B ( new_pendiente_B ) ;
setPromedio_de_t ( new_promedio_de_t ) ;
s etPromedio_de_x ( new_promedio_de_x ) ;
; setXt ( new_xt ) ;
}
public Model () {}
/ * *
* * /
private double intersection_A = 0 . 0;
/ * *
* * /
public void setIntersection_A ( double new_intersection_A )
[
intersection_A = new_intersection_A;
} [19659006] / * *
* * /
public double getIntersection_A () {
return intersection_A;
}
/ * ] *
* * /
private double x_por_t = 0 . 0;
/ * *
* * /
public void setX_por_t ( double new_x_por_t )
{
x_por_t = new_x_por_t;
System . out . println ( "Retrieving x_por_t = "
+ x_por_t ) ;
}
/ * *
* * /
public double getX_por_t () {
return x_por_t;
}
/ * ] *
* * /
private double sumatoria_de_x = 0 . 0;
/ * *
* * /
public void setSummary_of_x ( double new_summary_of_x )
{
summatory_of_x = new_summary_of_x;
} [19659006] / * *
* * /
public double getSumatoria_de_x () {
return sumatoria_de_x;
}
/ * ] *
* * /
private double sumatoria_t_por_x = 0 . 0;
/ * *
* * /
public void setSumatoria_t_por_x ( double new_summary_t_per_x )
{
sumatoria_t_por_x = new_summary_t_per_x;
} [19659006] / * *
* * /
public double getSumatoria_t_por_x () {
return sumatoria_t_por_x;
}
/ * ] *
* * /
private double t_elevado_al_quadrado = 0 . 0;
/ * *
* * /
public void setT_elevado_al_quadrado ( double new_t_elevado_al_quadrado )
{
t_elevado_al_quadrado = new_t_elevado_al_quadrado;
} [19659006] / * *
* * /
public double getT_elevado_al_quadrado () {
return t_elevado_al_quadrado;
}
/ * ] *
A2 ^ 2 + A3 ^ 2 + A4 ^ 2 + A5 ^ 2 + A6 ^ 2 + A7 ^ 2
* * /
private double sumatoria_t_elevado_al_quadrado = 0 . 0;
/ * *
A2 ^ 2 + A3 ^ 2 + A4 ^ 2 + A5 ^ 2 + A6 ^ 2 + A7 ^ 2
* * /
public void setSumatoria_t_elevado_al_cuadrado ( double nuevo_sumatoria_t_elevado_al_cuadrado )
{
I sumatoria_t_elevado_al_cuadrado = nuevo_sumatoria_t_elevado_al_cuadrado;
} [19659006] / * *
A2 ^ 2 + A3 ^ 2 + A4 ^ 2 + A5 ^ 2 + A6 ^ 2 + A7 ^ 2
* * /
public double getSumatoria_t_elevado_al_quadrado () {
return sumatoria_t_elevado_al_quadrado;
}
/ * ] *
* * /
private double sumatoria_t = 0 . 0;
/ * *
* * /
public void setSummary_t ( double new_summary_t )
{
sumatoria_t = new_summary_t;
} [19659006] / * *
* * /
public double getSumatoria_t () {
return sumatoria_t;
}
/ * ] *
* * /
private double pending_B = 0 . 0;
/ * *
* * /
public void setPendiente_B ( double new_pendent_B )
{
pending_B = new_pendant_B;
} [19659006] / * *
* * /
public double getPendiente_B () {
return pending_B;
}
/ * ] *
* * /
private double average_of_t = 0 . 0;
/ * *
* * /
public void setPromedio_de_t ( double new_promedio_de_t )
{
average_of_t = new_promedio_de_t;
} [19659006] / * *
* * /
public double getPromedio_de_t () {
return average_of_;
}
/ * ] *
* * /
private double average_of_x = 0 . 0;
/ * *
* * /
public void setPromedio_de_x ( double new_promedio_de_x )
{
average_of_x = new_promedio_de_x;
} [19659006] / * *
* * /
public double getPromedio_de_x () {
return average_of_x;
}
/ * ] *
It is the same as linear regression .
* * /
private double xt = 0 . 0;
/ * *
It is the same as linear regression .
* * /
public void setXt ( double new_xt )
[
xt = new_xt;
} [19659006] / * *
It is the same as linear regression .
* * /
public double getXt(){
return xt;
}
/**
Es lo mismo que getXt().
**/
public double getRegrecion_lineal(){
return xt;
}
/**
* @return the proximo_t
*/
public double getProximo_t() {
return proximo_t;
}
/**
* @param proximo_t the proximo_t to set
*/
public void setProximo_t(double proximo_t) {
this.proximo_t = proximo_t;
}
public void msjResultados(){
JOptionPane.showMessageDialog(null,"Sumatoria de x="+ this.getSumatoria_de_x() +
"nSumatoria de t=" + this.getSumatoria_t() + "nSumatoria de t al cuadrado=" + this.getSumatoria_t_elevado_al_cuadrado() +
"nSumatoria t*x=" + this.getSumatoria_t_por_x() +
"nT elevado al cuadrado=" + this.getT_elevado_al_cuadrado() +
"nPromedio de t=" + this.getPromedio_de_t() +
"nPromedio de x=" + this.getPromedio_de_x() +
"nPendiente B=" + this.getPendiente_B() + "nInterseccion A=" +
this.getInterseccion_A() + "nXt=" + this.getXt() + "nRegresion lineal=" + this.getRegrecion_lineal(), "Resultados globales", JOptionPane.INFORMATION_MESSAGE);
}
}//Fin del class
}
@Retention (RetentionPolicy.RUNTIME)//Permite retener las anotaciones en tiempo de ejecusion y estaran disponibles en tiempo de ejecusion.
@Target(ElementType.TYPE_USE)//Las anotaciones solo estan a nivel de variables globales y objetos globales.
@Documented()
@interface Rafael_Angel_Montero_Fernandez{
/**
*
* @return Devuelve el correo del programador por defecto.
*/
public String Correo() default "Sharkyc12@Gmail.com";
public String Numero_telefonico() default "+50683942235";
}
from Nettech Post http://bit.ly/2ER2FrM
No hay comentarios:
Publicar un comentario