Angel Vazquez

Media	
  Aritmética	
  

	
  

	
  

public function clickMedAri():void{
if(txtNumMedAri.text != "")
lblRes...
Angel Vazquez
Media	
  Ponderada	
  

	
  

[Bindable]
public var arrayMedPod:ArrayCollection = new ArrayCollection();
pub...
Angel Vazquez
Mediana	
  

	
  

public function clickMed():void{
var nums:Array
= txtNumMediana.text.split(",");
lblResul...
Angel Vazquez
Moda	
  

	
  

public function clickMed():void{
var nums:Array
= txtNumModa.text.split(",");
lblResultOrder...
Angel Vazquez
Rango	
  

public function clickRang():void{
var result:String = "";
if( txtNumRang.text != ""){
result = St...
Angel Vazquez
Varianza	
  

	
  

public function clickVar():void{
var nums:Array
= txtNumVar.text.split(",");
lblResultVa...
Angel Vazquez
Desviación	
  estándar	
  

	
  

public function clickDesEstand():void{
var nums:Array
= txtNumDesEstand.te...
Angel Vazquez
Covarianza	
  

	
  

	
  
public var length:uint = 0;
private var result:Number = 0;
public function clickV...
Angel Vazquez
{
arrayNumber[j] = arrayNumber[j - incremento];
j = j - incremento;
}
arrayNumber[j] = temp;
}
incremento = ...
Angel Vazquez
Sturges	
  

	
  

private function clickSturg():void {
var result:Number = 0;
var log:Number
= 0;
log = Mat...
Angel Vazquez
Datos	
  Atípicos	
  

	
  

private var media:Number
= 0;
private var desviacionEstand:Number = 0;
private ...
Angel Vazquez
}
public function calculateDesEstand(arreglo:Array):Number
{
var suma:Number
= 0;
var desviacion:Number
= 0;...
Upcoming SlideShare
Loading in …5
×

Pseudocodigo para soluciones de estadistica

761 views

Published on

Published in: Technology
2 Comments
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
761
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
8
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide

Pseudocodigo para soluciones de estadistica

  1. 1. Angel Vazquez Media  Aritmética       public function clickMedAri():void{ if(txtNumMedAri.text != "") lblResultMedAri.text = String(calculateMedAri( txtNumMedAri.text )); } public function calculateMedAri(num:String):Number{ var nums:Array = num.split(","); var sum:Number = 0; var result:Number = 0; for(var i:int = 0;i<nums.length;i++){ sum += Number(nums[i]); } result = sum/nums.length; return result; } 1  
  2. 2. Angel Vazquez Media  Ponderada     [Bindable] public var arrayMedPod:ArrayCollection = new ArrayCollection(); public function init():void{ mediaPonderada(); } public function mediaPonderada():void{ var data:DataVO = new DataVO(); data.peso = " "; data.valor = " "; arrayMedPod.addItem( data ); dgMedPond.dataProvider = arrayMedPod; } public function clickMedPond():void{ lblResult.text = String( calculateMedPond() ); } public function calculateMedPond():Number{ var resul:Number = 0; var sumPeso:Number = 0; var sumMulti:Number = 0; for(var i:int = 0; i < arrayMedPod.length ; i++){ sumPeso += Number(arrayMedPod[i].peso); sumMulti += (Number(arrayMedPod[i].peso) * Number(arrayMedPod[i].valor)); } resul = sumMulti/sumPeso; return resul; }   2  
  3. 3. Angel Vazquez Mediana     public function clickMed():void{ var nums:Array = txtNumMediana.text.split(","); lblResultOrder.text = String(orderMed(nums,nums.length)); lblResultMediana.text = String(calculateMed(orderMed(nums,nums.length))); } public function orderMed(arrayNumber:Array,length:uint):Array{ var j:uint; var incremento:uint; var temp:uint; incremento = length / 2; while (incremento>0){ for ( var i:uint=incremento; i<length; i++){ j = i; temp = arrayNumber[i]; while ((j >= incremento) && (arrayNumber[j-incremento] > temp)){ arrayNumber[j] = arrayNumber[j - incremento]; j = j - incremento; } arrayNumber[j] = temp; } incremento = incremento/2; } return arrayNumber; } public function calculateMed(arrayNum:Array):Number{ var result:Number = 0; var posi:int = 0; if( arrayNum.length % 2 == 0 ){ posi = arrayNum.length / 2; posi -=1 result = (Number(arrayNum[posi]) + Number(arrayNum[posi+1]))/2; }else{ posi = arrayNum.length/2 result = arrayNum[posi]; } return result; } 3  
  4. 4. Angel Vazquez Moda     public function clickMed():void{ var nums:Array = txtNumModa.text.split(","); lblResultOrder.text = String(orderMed(nums,nums.length)); lblResultModa.text = String(calculateMod(orderMed(nums,nums.length))); } public function orderMed(arrayNumber:Array,length:uint):Array{ var j:uint; var incremento:uint; var temp:uint; incremento = length / 2; while (incremento>0){ for ( var i:uint=incremento; i<length; i++){ j = i; temp = arrayNumber[i]; while ((j >= incremento) && (arrayNumber[j-incremento] > temp)){ arrayNumber[j] = arrayNumber[j - incremento]; j = j - incremento; } arrayNumber[j] = temp; } incremento = incremento/2; } return arrayNumber; } public function calculateMod(arrayNum:Array):Number{ var maximaVecesQueSeRepite:uint = 0; var moda:Number = 0; for(var i:uint=0; i<arrayNum.length; i++){ var vecesQueSeRepite:uint = 0; for(var j:uint=0; j<arrayNum.length; j++){ if(arrayNum[i] == arrayNum[j]) vecesQueSeRepite++; } if(vecesQueSeRepite > maximaVecesQueSeRepite){ moda = arrayNum[i]; maximaVecesQueSeRepite = vecesQueSeRepite; } } return moda; } 4  
  5. 5. Angel Vazquez Rango   public function clickRang():void{ var result:String = ""; if( txtNumRang.text != ""){ result = String(calculateRang( txtNumRang.text )); lblResultRang.text = result; } }   public function calculateRang(num:String):Number{ var nums:Array = num.split(","); var result:Number = 0; result = Number(nums[nums.length-1]) - Number(nums[0]); return result; }                                         5  
  6. 6. Angel Vazquez Varianza     public function clickVar():void{ var nums:Array = txtNumVar.text.split(","); lblResultVar.text = String(calculateVar( nums )); } public function calculateVar(arreglo:Array):Number{ var suma:Number = 0; var media:Number = 0; var desviacion:Number = 0; var diferencia:Number = 0; var result:Number = 0; for(var i:uint = 0; i < arreglo.length; i++){ suma+= Number(arreglo[i]); } media = suma / arreglo.length; for(var j:uint = 0; j < arreglo.length; j++){ diferencia = (Number(arreglo[j]) - media); desviacion += (diferencia * diferencia); } desviacion = desviacion/arreglo.length; desviacion = Math.sqrt(desviacion); result = desviacion*desviacion; return result; } 6  
  7. 7. Angel Vazquez Desviación  estándar     public function clickDesEstand():void{ var nums:Array = txtNumDesEstand.text.split(","); lblResultDesEstand.text = String(calculateDesEstand( nums )); } public function calculateDesEstand(arreglo:Array):Number{ var suma:Number = 0; var media:Number = 0; var desviacion:Number = 0; var diferencia:Number = 0; for(var i:uint = 0; i < arreglo.length; i++){ suma+= Number(arreglo[i]); } media = suma / arreglo.length; for(var j:uint = 0; j < arreglo.length; j++){ diferencia = (Number(arreglo[j]) - media); desviacion += (diferencia * diferencia); } desviacion = desviacion/arreglo.length; desviacion = Math.sqrt(desviacion); return desviacion; }                                 7  
  8. 8. Angel Vazquez Covarianza       public var length:uint = 0; private var result:Number = 0; public function clickVar():void{ var numsX:Array = txtNumVarX.text.split(","); var numsY:Array = txtNumVarY.text.split(","); if( numsX.length == numsY.length) { lenta = numsX.length; result = sumXY(numsX,numsY) - (calculateMed(orderMed( numsX,length )) * calculateMed(orderMed( numsY,length ))); lblResultcovar.text = String(result); } else Alert.show("El numero de datos de X y Y n debe de ser del mismo numero","Error"); } public function sumXY( arrayX:Array, arrayY:Array ):Number { var sum:Number = 0; for(var i:uint = 0; i < arrayX.length; i++) { sum += (Number(arrayX[i]) * Number(arrayY[i])) / length; } return sum; } public function orderMed(arrayNumber:Array,length:uint):Array{ var j:uint; var incremento:uint; var temp:uint; incremento = length / 2; while (incremento>0) { for ( var i:uint=incremento; i<length; i++) { j = i; temp = arrayNumber[i]; while ((j >= incremento) && (arrayNumber[j-incremento] > temp)) 8  
  9. 9. Angel Vazquez { arrayNumber[j] = arrayNumber[j - incremento]; j = j - incremento; } arrayNumber[j] = temp; } incremento = incremento/2; } return arrayNumber; } public function calculateMed(arrayNum:Array):Number{ var result:Number = 0; var posi:int = 0; if( arrayNum.length % 2 == 0 ) { posi = arrayNum.length / 2; posi -=1; result = (Number(arrayNum[posi]) + Number(arrayNum[posi+1]))/2; }else { posi = arrayNum.length/2; result = arrayNum[posi]; } return result; }                                                 9  
  10. 10. Angel Vazquez Sturges     private function clickSturg():void { var result:Number = 0; var log:Number = 0; log = Math.log((Number(txtLog.text))) * Math.LOG10E; result = 1+3.322 * log; lblResultLog.text = String(result); }                                                                 10  
  11. 11. Angel Vazquez Datos  Atípicos     private var media:Number = 0; private var desviacionEstand:Number = 0; private var limitSuper:Number = 0; private var limitInfer:Number = 0; private var arrayAtipicos:Array; private var arrayTipicos:Array; public function clickVar():void{ var nums:Array = txtNumVar.text.split(","); desviacionEstand = calculateDesEstand(orderMed( nums, nums.length )); limitSuper = (media + (Number(txtDesv.text) * desviacionEstand)); limitInfer = (media - (Number(txtDesv.text) * desviacionEstand)); calculateAtipicos( orderMed( nums, nums.length ) ); calculateTipicos( orderMed( nums, nums.length ) ); lblMedia.text = String( media ); lblResultOrder.text = String(orderMed( nums, nums.length )); lblDesvEstand.text = String(desviacionEstand); lblLimitSuper.text = String( limitSuper ); lblLimitInfer.text = String( limitInfer ); } public function orderMed(arrayNumber:Array,length:uint):Array { var j:uint; var incremento:uint; var temp:uint; incremento = length / 2; while (incremento>0) { for ( var i:uint=incremento; i<length; i++) { j = i; temp = arrayNumber[i]; while ((j >= incremento) && (arrayNumber[j-incremento] > temp)) { arrayNumber[j] = arrayNumber[j - incremento]; j = j - incremento; } arrayNumber[j] = temp; } incremento = incremento/2; } return arrayNumber; 11  
  12. 12. Angel Vazquez } public function calculateDesEstand(arreglo:Array):Number { var suma:Number = 0; var desviacion:Number = 0; var diferencia:Number = 0; for(var i:uint = 0; i < arreglo.length; i++) { suma+= Number(arreglo[i]); } media = suma / arreglo.length; for(var j:uint = 0; j < arreglo.length; j++) { diferencia = (Number(arreglo[j]) - media); desviacion += (diferencia * diferencia); } desviacion = desviacion/arreglo.length; desviacion = Math.sqrt(desviacion); return desviacion; } private var j:uint = 0; public function calculateAtipicos(nums:Array):void { arrayAtipicos = new Array(); j = 0; for(var i:uint = 0;i<nums.length;i++) { if( limitInfer >= Number(nums[i]) ) { arrayAtipicos[j] = nums[i]; j++; } else if( limitSuper <= Number(nums[i]) ) { arrayAtipicos[j] = nums[i]; j++; } } lblResultVar.text = String(arrayAtipicos); } private var h:uint = 0; public function calculateTipicos(nums:Array):void { arrayTipicos = new Array(); h = 0; for(var i:uint = 0;i<nums.length;i++) { if( limitInfer <= Number(nums[i]) && limitSuper >= Number(nums[i])) { arrayTipicos[h] = nums[i]; h++ } } lblResultVa2.text = String(arrayTipicos); } 12  

×