ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/muc_randvar.h
Revision: 2.1
Committed: Thu Jul 14 17:32:12 2016 UTC (7 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad5R3, rad5R1, HEAD
Log Message:
Changes to evalglare by Jan Wienold

File Contents

# Content
1 /* RCSid $Id$ */
2 /*
3 ** Author: Christian Reetz ([email protected])
4 */
5 #ifndef __MUC_RANDVAR_H
6 #define __MUC_RANDVAR_H
7
8 /** \file muc_randvar.h
9 * \author Ch. Reetz ([email protected])
10 * \brief representation of a random variables of arbitrary dimension
11 */
12
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #include "g3flist.h"
19
20 /** random variable structure*/
21 struct muc_rvar {
22 int n; /* number of samples */
23 double w; /* sum of weights*/
24 double* sum; /* sample values sum*/
25 double* sum_sqr; /* squared sample values sum*/
26 double* min; /* minimum component value*/
27 double* max; /* maximum component value*/
28 g3FList* samples; /* measured samples (if saved)*/
29 int save_samp; /* if true (default) save samples*/
30 };
31
32 /* returns dimension of random variable*/
33 #define muc_rvar_get_dim(rv) (g3fl_get_comp_size(rv->samples))
34 /* returns the number of samples*/
35 #define muc_rvar_get_sample_size(rv) (rv->n)
36
37 /* returns a reference to a sample list element*/
38 /* Take care to have save_samp flag set*/
39 #define muc_rvar_get_sample(rv,id) (g3fl_get(rv->samples, id))
40
41
42 int muc_rvar_init(struct muc_rvar* rv);
43 struct muc_rvar* muc_rvar_create();
44 void muc_rvar_free(struct muc_rvar* rv);
45
46 /* set dimension of random variable (default 1). */
47 /* random variable needs to be empty (\see muc_rvar_clear)*/
48 int muc_rvar_set_dim(struct muc_rvar* rv,int dim);
49
50 /* set storing samples on (default) or off*/
51 /* random varianle must be cleared to succeed*/
52 int muc_rvar_store_sample(struct muc_rvar* rv, int on);
53
54 /* clear random variables samples. Don't change dimension.*/
55 void muc_rvar_clear(struct muc_rvar* rv);
56
57 /* Don't store measured sample values, just summed values.*/
58 /* (Deletes samples if there are already stored some)*/
59 void muc_rvar_no_samples(struct muc_rvar* rv);
60
61 /* adds measured sample to sums (and stores them if \ref save_samp is true)*/
62 /* The weight of the sample is assumed to be 1.0*/
63 int muc_rvar_add_sample(struct muc_rvar* rv,double* sample);
64
65 /* adds \param w weighted sample to sums */
66 /* (and stores them if \ref save_samp is true)*/
67 int muc_rvar_add_weighted_sample(struct muc_rvar* rv,double w,double* samp);
68
69 /* returns current expected value in \param ex*/
70 int muc_rvar_get_ex(struct muc_rvar* rv,double* ex);
71
72 /* returns current variance in \param vx*/
73 int muc_rvar_get_vx(struct muc_rvar* rv,double* vx);
74
75 /* returns current bounds*/
76 /* \param bounds: array with len 2*component_size */
77 /* \return {min1, max1, min2, max2....}*/
78 int muc_rvar_get_bounding_box(struct muc_rvar* rv, double* bounds);
79
80 /* return sample median (using averaging for even sample numbers)*/
81 /* \return false if samples are not stored*/
82 int muc_rvar_get_median(struct muc_rvar* rv, double* median);
83
84 int muc_rvar_get_percentile(struct muc_rvar* rv, double* median, double percentile);
85
86 #ifdef __cplusplus
87 }
88 #endif
89 #endif