Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/04/2015, 20:06
Avatar de dorde
dorde
 
Fecha de Ingreso: diciembre-2003
Mensajes: 145
Antigüedad: 20 años, 5 meses
Puntos: 7
Respuesta: Promedio en pho

muchas gracias
acabe calculando varianza asi, le puse ingenio......

<?php
echo "Calculo de varianza","<br>";

if(!empty($_POST)):
$arreglo[]=$_POST['numero'];
foreach($_POST['numeros'] as $numero):
$arreglo[]=$numero;
endforeach;
$suma=array_sum($arreglo);
$cantidad=count($arreglo);
$promedio=$suma/$cantidad;
foreach ($arreglo as $operacion):
$suma_operacion+=((($operacion-$promedio)*($operacion-$promedio))/$cantidad);
endforeach;

echo "Cantidad : ",$cantidad, "<br>";
echo "Promedio : ",$promedio,"<br>";
echo "Varianza :",$suma_operacion,"<br>";

#print_r($arreglo);
endif;
?>
<form method="post" action="varianza3.php">
Numero: <input type="text" name="numero" value="">

<?php foreach($arreglo as $id => $numeros):
?>

<input type="hidden" name="numeros[<?php echo $id;?>]" value="<?php echo $numeros;?>">

<?php
endforeach;
?>
<input type="submit" name="submit" value="Calcular">
</form>
<?php

/*
* 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.
*/
__________________
Pero si alguno de vosotros se ve falto de sabiduría, que la pida a Dios, el cual da a todos abundantemente y sin reproche, y le será dada. Pero que pida con fe, sin dudar

Santiago 1.5-6