public function citySalary() { //It will apply the query into the database and return the data $var = "Emprego.Numero_de_Vinculos_Empregaticios.Ativos.Rendimento_medio"; $citiesSalary = new CitiesController(); $salary = $citiesSalary->selectData(array($var => true, 'Municipio' => true, "_id" => false)); $zTransform = new ZtransformController(); $salaryAvg = array(); for ($i = 0; $i < sizeof($salary); $i++) { //Select data of each city $salaryValues = $salary[$i]["Emprego"]["Numero_de_Vinculos_Empregaticios"]["Ativos"]["Rendimento_medio"]; //Make the average and save it in an array $salaryAvg = array_merge($salaryAvg, array($salary[$i]["Municipio"] => $zTransform->calculateAverage($salaryValues, sizeof($salary)))); } //Calculate and return Z-values return $zTransform->zTransformation($salaryAvg); }
/** * Calculte the average and z-transform of the amount of companies of each city * @return Return the z-transform for numbe of companies of each city */ public function cityCompanies() { //It will apply the query into the database and return the data $var = "Emprego.Numero_de_Estabelecimentos.Total"; $citiesCompanies = new CitiesController(); $companies = $citiesCompanies->selectData(array($var => true, 'Municipio' => true, "_id" => false)); //Make number of compnies average $zTransform = new ZtransformController(); $companiesAvg = array(); for ($i = 0; $i < sizeof($companies); $i++) { //Select data of each city $companiesValues = $companies[$i]["Emprego"]["Numero_de_Estabelecimentos"]["Total"]; //Make the average and save it in an array $companiesAvg = array_merge($companiesAvg, array($companies[$i]["Municipio"] => $zTransform->calculateAverage($companiesValues, sizeof($companies)))); } //Calculate and return Z-values return $zTransform->zTransformation($companiesAvg); }
/** * Calculte the average and z-transform of number of people drinking water from a public water supply * @return Return the z-transform for of number of people using drinking water from a public water supply */ public function publicWaterSupply() { //It will apply the query into the database and return the data $var = "Domicilios_Particulares_Permanentes.Por_Abastecimento_de_Agua.Rede_Geral.Total"; $cityPublicSupply = new CitiesController(); $publicSupply = $cityPublicSupply->selectData(array($var => true, 'Municipio' => true, "_id" => false)); //Make public water supply's average and z-values $zTransform = new ZtransformController(); $publicSupplyAvg = array(); for ($i = 0; $i < sizeof($publicSupply); $i++) { //Select data of each city $publicSupplyValues = $publicSupply[$i]["Domicilios_Particulares_Permanentes"]["Por_Abastecimento_de_Agua"]["Rede_Geral"]["Total"]; //Make the average and save it in an array $publicSupplyAvg = array_merge($publicSupplyAvg, array($publicSupply[$i]["Municipio"] => $zTransform->calculateAverage($publicSupplyValues, sizeof($publicSupply)))); } //Calculate and return Z-values return $zTransform->zTransformation($publicSupplyAvg); }
/** * Make the z-transform of averages of the cities * @param array $munAverages * @return Return a array with the z value of each city */ public function zTransformation($munAverages) { //make average of given cities' averages $sumAvg = 0; $avg = 0; foreach ($munAverages as $key => $value) { $sumAvg += $value; } $avg = $sumAvg / sizeof($munAverages); //Calculate Standard Deviation $std = ZtransformController::standarDeviation($munAverages, $avg); //Apply the z-transform and save the results in an array $zValues = array(); //keep the z-transform results $zTransform = 0; foreach ($munAverages as $key => $value) { $zTransform = ($value - $avg) / $std; $zValues = array_merge($zValues, array($key => $zTransform)); } return $zValues; }
/** * Calculte the average and z-transform of number of people using river,lake or sea to dispose thei sewer on each city * @return Return the z-transform for of number of people using river,lake or sea to dispose thei sewer on each city */ public function drainageDitch() { //It will apply the query into the database and return the data $var = "Domicilios_Particulares_Permanentes.Por_Tipo_de_Esgotamento_Sanitario.Vala.Total"; $cityDrainageDitch = new CitiesController(); $drainageDitch = $cityDrainageDitch->selectData(array($var => true, 'Municipio' => true, "_id" => false)); //Make otherSewer's average and z-values $zTransform = new ZtransformController(); $drainageDitchAvg = array(); for ($i = 0; $i < sizeof($drainageDitch); $i++) { //Select data of each city $drainageDitchValues = $drainageDitch[$i]["Domicilios_Particulares_Permanentes"]["Por_Tipo_de_Esgotamento_Sanitario"]["Vala"]["Total"]; //Make the average and save it in an array $drainageDitchAvg = array_merge($drainageDitchAvg, array($drainageDitch[$i]["Municipio"] => $zTransform->calculateAverage($drainageDitchValues, sizeof($drainageDitch)))); } //Calculate and return Z-values return $zTransform->zTransformation($drainageDitchAvg); }
/** * Calculte the average and z-transform of the city Government expending * @return Return the z-transform for of Government expending */ public function governmentExpending() { //It will apply the query into the database and return the data $var = "Financas_Publicas.Despesas_Realizadas.Total"; $governmentExpending = new CitiesController(); $expending = $governmentExpending->selectData(array($var => true, 'Municipio' => true, "_id" => false)); //Make other state expending' average and z-values $zTransform = new ZtransformController(); $expendingAvg = array(); for ($i = 0; $i < sizeof($expending); $i++) { //Select data of each city $expendingValues = $expending[$i]["Financas_Publicas"]["Despesas_Realizadas"]["Total"]; //Make the average and save it in an array $expendingAvg = array_merge($expendingAvg, array($expending[$i]["Municipio"] => $zTransform->calculateAverage($expendingValues, sizeof($expending)))); } //Calculate and return Z-values return $zTransform->zTransformation($expendingAvg); }
/** * Calculte the average and z-transform of dropout rate in Elementary and Middle school or High School. * Number of students who graduated at elementary school in a given year X * @return Return the z-transform for of failure rate in Elementary and Middle school or High School */ public function schoolNumberGraduates($schoolGrade) { //It will apply the query into the database and return the data $var = "Educacao." . $schoolGrade . ".Numero_de_Concluintes.Total"; $cityNumberGraduates = new CitiesController(); $numberGraduates = $cityNumberGraduates->selectData(array($var => true, 'Municipio' => true, "_id" => false)); //Make other preschool enrllments' average and z-values $zTransform = new ZtransformController(); $numberGraduatesAvg = array(); for ($i = 0; $i < sizeof($numberGraduates); $i++) { //Select data of each city $numberGraduatesValues = $numberGraduates[$i]["Educacao"][$schoolGrade]["Numero_de_Concluintes"]["Total"]; //Make the average and save it in an array $numberGraduatesAvg = array_merge($numberGraduatesAvg, array($numberGraduates[$i]["Municipio"] => $zTransform->calculateAverage($numberGraduatesValues, sizeof($numberGraduates)))); } //Calculate and return Z-values return $zTransform->zTransformation($numberGraduatesAvg); }