Home | Develop | Download | Contact
example_hb.c
1 /*
2  * example_hb.c
3  *
4  * Copyright 2011 Fernando Pujaico Rivera <fernando.pujaico.rivera@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  *
21  */
22 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <pds/pdsmath.h>
32 
33 int main(int argc, char** argv)
34 {
35  double x,y,z;
36 
37  for(x=0.0001;x<0.5;x=x+0.05)
38  {
39  y=pds_hb(x);
40  z=pds_hbinv(y);
41 
42  printf("x=%f\ty=hb(x)=%f\n",x,y);
43  printf("z=hbinv(y)=%f\t",z);
44  printf("ERROR=%f ppm\n",(x-z)*1000000/x);
45  }
46 
47  return EXIT_SUCCESS;
48 }
double pds_hb(double x)
Evalúa la función de entropía binaria Hb(x)=-x*log2(x)-(1-x)*log2(1-x).
double pds_hbinv(double h)
Retorna el valor x de la función de entropía binaria para un valor de h aproximadamente igual a Hb(x)...

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed