Home | Develop | Download | Contact
pdscoin.h
1 /*
2  * extras.h
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 
32 #ifndef __PDSCOIN_H__
33 #define __PDSCOIN_H__
34 
35 #include <pds/pdsrv.h>
36 #include <pds/pdsra.h>
37 //#include <pds/pdsba.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
52 #define PDS_MIN_COIN_PROB 1.0/PDS_RAND_MAX
53 
54 
65 typedef struct
66 {
76 }PdsCoin;
77 
89 
100 int pds_coin_init(PdsCoin *X, PdsRvReal x0);
101 
112 int pds_coin_set_p(PdsCoin *X, PdsRvReal p);
113 
125 
137 
149 
161 
172 int pds_coin_get_vector(PdsCoin *X, PdsVector *V);
173 
180 void pds_coin_free(PdsCoin *X);
181 
188 void pds_coin_destroy(PdsCoin **X);
189 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* __PDSCOIN_H__ */
PdsRvReal p
Definition: pdscoin.h:75
La estructura tipo PdsCoin. Esta estructura genera una variable aleatoria de Bernoulli. Para usar, incluir pdsrv/pdsrv.h. La función de densidad de probabilidad es: fx(x=1)=p, fx(x=0)=1-p, fx(x=other)=0 .
Definition: pdscoin.h:65
int pds_coin_get_value(PdsCoin *X, PdsRvReal *x)
Pide un valor {-1,1} a la variable aleatoria de tipo PdsCoin.
int pds_coin_get_last_value(PdsCoin *X, PdsRvReal *x)
Pide el último valor {-1,1} obtenido de la variable aleatoria de tipo PdsCoin.
int pds_coin_get_vector(PdsCoin *X, PdsVector *V)
Pide un vector de valores {-1,+1} a la variable aleatoria de tipo PdsCoin.
float PdsRvReal
Definition: pdsrvglobal.h:59
void pds_coin_destroy(PdsCoin **X)
Libera la variable aleatoria de tipo puntero PdsCoin, y la carga con NULL.
La estructura tipo PdsCongruential. Esta estructura genera una secuencia aleatoria congruential...
void pds_coin_free(PdsCoin *X)
Libera la variable aleatoria de tipo puntero PdsCoin.
int pds_coin_get_bit(PdsCoin *X, PdsRvByte *x)
Pide un valor {0,1} a la variable aleatoria de tipo PdsCoin.
int pds_coin_set_p(PdsCoin *X, PdsRvReal p)
Inicia con una probabilidad de p a la variable aleatoria de tipo PdsCoin.
PdsCongruential * X1
Definition: pdscoin.h:69
int pds_coin_get_last_bit(PdsCoin *X, PdsRvByte *x)
Pide el último valor {0,1} obtenido de la variable aleatoria de tipo PdsCoin.
PdsRvReal x
Definition: pdscoin.h:72
int pds_coin_init(PdsCoin *X, PdsRvReal x0)
Inicia con un valor x0 {-1,+1} a la variable aleatoria de tipo PdsCoin.
unsigned char PdsRvByte
Definition: pdsrvglobal.h:89
PdsCoin * pds_coin_new(PdsRvReal p)
Crea una variable aleatoria de tipo PdsCoin.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed