Home | Develop | Download | Contact
example_coin.c

Experimento de lanzar una moneda 16 veces.
Una moneda, com probabilidade 0.5 de ser "cara", es lanzada 16 veces y los resultados son observads. Para este propósito es creada una variable aleatoria binaria {1,-1}, aquí esta estructura (variable aleatoria) es llamada PdsCoin y reresenta una moneda de probabilidad p de ser 1.

Autor
Fernando Pujaico Rivera
Fecha
18-08-2016
/*
* example_coin.c
*
* Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
/* gcc -o example_coin example_coin.c -lpdsrv */
#include <stdio.h>
#include <pds/pdsrv.h>
int main(int argc, char** argv)
{
PdsCoin *Coin=NULL;
int i;
/* Creando una moneda con Pr(Coin=1)=0.5 */
Coin=pds_coin_new(0.5);
for(i=0;i<16;i++)
{
/* Obteniendo el resultado de lanzar una moneda */
pds_coin_get_value(Coin, &x);
/* Mostrando el resultado por pantalla */
printf("Coin:\t%f\n",x);
}
return EXIT_SUCCESS;
}

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed