Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.46 KB | None | 0 0
  1. @Override
  2. public void init(){
  3. int n1 = 200, m = 0, soma, count, a, media, R1 = 0, R2 = 0;
  4. double [] machine_1 = {3.969663833734519,0.8743452080059965,1.6329575534956278,1.047406529617088,4.569322986912527,1.8671653010525844,0.9964116931203572,2.112365176983119,2.175159163505722,2.236618513688995,3.5205981717708315,1.621021994424638,2.087275851271255,0.8641891469544634,5.582950871439082,0.8856403639019336,0.33411643620357734,1.146559641068486,0.6299144842324754,0.9058098307373268,0.8360675244561641,2.592472167116428,2.668968752515135,0.5466653451706609,1.9688224365222062,0.21968126151643927,2.1068799142149177,1.1456025681253763,2.2066788417155245,0.49058091000263493,0.6800821114115237,3.386495133020513,0.8657857949014662,2.9976738143469253,1.52718443282169,2.1104186032405363,2.168760804728826,3.6884778834170766,2.892548335254654,2.1050648635922364,2.241843168619552,1.1624757020114178,2.308797611365957,1.410827181277386,0.5320575800179298,0.5998878865613834,1.091947569714463,3.3776455860975108,1.5278113686901214,3.0065319582943912,1.265396758867418,1.0489146964964784,1.0243059572149114,3.3477441110345616,3.1367827930458905,2.7593305312156753,2.3184521860199645,1.8907104429418058,0.8058814342716845,3.807318765257875,4.477626245091765,1.8046413115005502,1.4462610081222966,1.271411681138714,3.140502432251459,1.2682300574239367,1.6134325927565139,2.3114355842128096,2.085079909456707,2.1170050020533844,3.3981913787972657,1.8584271156096606,3.9902117996835873,2.0037016750198147,0.8336604214577864,4.320838100426281,2.962185359282051,0.4698798659853185,2.848460377107407,0.057582075447646715,4.820166437306053,1.329563616776053,4.256740197400888,3.037711557346063,2.4476577767184704,0.852768014485122,4.018909207225173,1.818351248376554,2.2715082609949344,0.9779672929085881,1.8230565809617163,0.8222524831677616,1.3042274860722165,2.8162333244033917,0.7716919998381364,2.279911143433447,4.060877438813454,2.515523018880098,1.2259384851879012,1.3737580681117232,2.3798538299857595,2.48124085002295,2.1319936976092118,2.346158696691954,3.4591339730105393,1.0819607634405857,1.8801944750229636,0.7608845731705896,2.8373087199066362,1.940322404182833,1.9156197548994147,2.1182700348726518,1.184840956412191,2.3922735121176077,1.053672720166939,2.146649140339891,0.9331887100093281,5.535400294284469,3.0802545022351335,2.2349676359253743,4.756731930680237,1.2976749468797268,2.439063623496262,1.5706689720070102,0.2045554233890928,1.939840440732576,2.6120329189982896,0.8483061797318849,1.6069258229147132,3.73226569450751,1.9286108095848324,2.748020018171828,1.419627680427497,2.1466774679324248,0.8713346093740691,2.6135141598722402,1.2132535473189048,4.186346888810476,2.577997463818452,4.164059844898095,2.6607308165866446,0.38188273652773636,1.6283147587065958,0.26813714603385363,2.9871450843342413,1.1045024250409947,4.770188007861512,2.998135662124136,1.1524500856012423,3.513613805482949,2.2073319130837032,1.7638368540130867,3.7500546412850952,2.634824644386519,1.3656103313795906,2.5064791477508086,0.6785367268220713,3.4057296795384144,2.4210289164383334,3.2069694931183426,3.140573257116156,1.0722047595429247,0.9398754586823537,1.4259052383381692,2.943600618151538,5.221401290615739,1.804377118969525,1.3403662966997054,0.2029040046039673,1.5714317670433466,1.219063871841728,2.5752592385494286,2.6256138411183123,0.6448645013887333,2.2275032284147143,0.7625268307952489,2.64518180206303,2.2663611919230937,1.3267301806374316,3.2451586845602565,1.3564126695439127,3.4965471537033337,2.354950255258938,4.241285872440189,2.3154585690785523,0.814119141768295,1.9250097552106173,1.2930719891017548,2.5019688890290968,1.0699604317245068,2.423814823124267,2.3772048993050907,0.6893091564598862,0.13265099327923094,2.74440213652177,3.0723000530118756,1.146109694528448,0.6373762968270007,2.2420580047567245,1.0283195762998896};
  5. double [] machine_2 = {2.3414833670608526,3.652392676195641,1.086620247413073,1.3551960383831432,3.780165267839924,1.7851664551109439,1.5691426187857591,1.8291990930083735,3.1645366970949422,1.239260798113258,2.9461618570124273,2.6888878421285742,2.203536487183345,2.422335549568766,1.01384084238888,1.243714908081664,2.4771719519444457,1.4600666845776833,0.36856232685312107,1.2011776829571152,0.544743185985057,1.1738074527235265,1.2333674641398775,0.9334338028031306,3.6054741501889884,1.0423367087542426,1.865925314147356,3.020824507059587,2.318935331625422,2.0419490384715764,0.5399442684326922,1.3175407780823323,4.945758846847904,0.3713040944657696,0.7771355767721826,1.8991483596380319,2.014954610544402,1.2290917521393319,1.771189691065464,1.3714996762894665,0.7065877733872675,2.3595514858473767,0.40482589152250303,2.692745843305988,2.7716056940902605,1.1935843476644525,0.7440657570230665,1.6321851559675085,2.069891741398477,0.4404265380164842,1.2891280863961119,1.5538455747853788,1.5202476164712626,1.5309149839846827,2.3288652108144845,2.2676732735078247,2.1418931930016982,3.5380655563851193,2.799653950967681,1.1175657725068406,0.9425011273763089,1.8075996852763034,1.2203398539254797,1.3395596476894451,1.930468857483648,3.453515722665372,0.46414434517967773,2.1503380725438883,1.3165831248373823,1.3295652647475573,0.7441198419076024,2.766403912328539,0.700262264964698,1.4883236850425605,2.7674882341928893,0.6256031948229901,0.41779128239748003,1.0855371997983334,1.785984032007789,2.4446705655846337,0.8333565098686512,1.227055524870172,1.781479025393274,1.656416511510851,3.4656756223324856,1.3951499615471585,3.053562999953939,2.0689805960785583,0.974232699072303,2.119037411466465,1.6075999987348804,3.3082057215126555,4.298544144515739,1.3205348555885117,1.2085740550308692,3.6493239694605633,1.2734169580847983,2.357449387358439,1.829797905981437,1.554557220204675,1.2088462439913004,1.77723475659203,1.1339354470862393,1.7508188521463708,2.5007689248789506,2.9543012217891005,1.8529117152903662,1.7903121403496716,1.59086254657518,0.9688316658385031,2.60165935275002,1.3013813513660948,1.1305198376479866,0.5450812910806364,2.5474254517032953,2.667248974575092,1.9269861171090812,1.2817491157250305,1.6232391574055536,1.035641655084172,1.6148738804814435,0.8266135219557245,1.8882813711756332,2.906215229863229,1.658447977117455,1.156497434210183,0.8648209704880012,1.2233084600002533,1.4936413738638423,1.6119696445904148,3.1955713372566508,1.6069545278148287,2.428353984558431,2.046205970858573,2.4720026468189245,1.5087721719959815,1.3673575432589702,1.3710636220820087,2.8563273083267844,0.7557075059392845,2.1178042041304015,2.299107646203526,2.3639309224959324,1.0039994227133264,2.1967683799563624,1.7592830844286185,2.979320967966361,1.115046046620462,2.768131264381665,1.9723852214631516,2.180363217138386,2.3222915259289296,0.8797398110873524,1.8921819153320496,1.7000726012593697,2.112347486059855,3.414812666821189,2.2157505558106143,2.6683539550689477,3.779215027323069,1.5510137923419203,0.35550814107719797,1.0227376835579145,2.4673676069036956,2.1982294967369853,1.6019019866190243,1.3967830448086205,2.440539701632915,1.348106130334944,2.2145354938861086,0.9873873358108838,0.3225585986422642,1.5350701977649606,1.2655426800039544,1.856909535988583,2.2129273462509174,1.1831031500851836,0.5163501995441663,1.5267790190081496,2.018259390207836,0.39870418156303244,1.0105025581486433,3.3401304201387854,1.5167579559870008,1.0928442150147677,1.232434669381172,2.7013047185951464,1.1941903816959722,0.7621014630491655,1.2997940184712093,1.9814782119876508,0.7367272915442062,3.0186566378051936,2.855013137004243,1.8218590768300704,1.0473862461035683,2.5265513354725657,2.0580448191896146,0.406008557848053,0.8479596170845225};
  6. double [] sorted = new double[n1+n1];
  7. //double [] machine_1 = new double[n+n];
  8. //double [] machine_2 = new double[n+n];
  9. int [] rank = new int[n1+n1];
  10.  
  11. /*for(int l=0;l<n*2;l++){
  12. if(l%2 == 0){
  13. machine_1[l] = aux_1[m];
  14. machine_2[l] = aux_2[m];
  15. }
  16. m++;
  17. }*/
  18.  
  19. for(int i=0;i<n1*2;i++){
  20. if(i<n1){
  21. sorted[i] = machine_1[i];
  22. }
  23. else{
  24. sorted[i] = machine_2[i-n1];
  25. }
  26. }
  27.  
  28. //ordenar as observações por ordem crescente
  29. Arrays.sort(sorted);
  30.  
  31. //rank
  32. for(int j=0;j<=n1*2;j++){
  33. a = j + 1;
  34. soma = j + 1;
  35. count = 1;
  36.  
  37. while(sorted[j] == sorted[a]){
  38. soma = soma + a + 1;
  39. count++;
  40. a++;
  41. }
  42.  
  43. media = soma/count;
  44.  
  45. for(int p = j;p<a;p++){
  46. rank[p] = media;
  47. }
  48. }
  49.  
  50. //calcular R1 e R2
  51. for(int q = 0;q<2*n1;q++){
  52. if(Arrays.asList(machine_1).contains(sorted[q])){
  53. R1 = R1 + rank[q];
  54. }
  55. else{
  56. R2 = R2 + rank[q];
  57. }
  58. }
  59.  
  60. //calcular H
  61. double H, sum = 0;
  62. int n = 400, n2 = n1, k = 2;
  63.  
  64. for(int r = 1; r<=k;r++){
  65. if(r == 1){
  66. sum = sum + ((R1*R1)/n1 - 3*(n+1));
  67. }
  68. else{
  69. sum = sum + ((R2*R2)/n2 - 3*(n+1));
  70. }
  71. }
  72.  
  73. H = 12/(n*(n+1))+sum;
  74.  
  75. //Rejection Region, decisão e conclusão
  76. if(H > 3.84){
  77. System.out.println("Rejeitamos H0.\n");
  78. }
  79. else{
  80. System.out.println("Não rejeitamos H0.\n");
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement