17 #if defined __cplusplus
27 char const *toUnits[3] ) {
30 double norm, wUnitFactor;
31 char const *wFromUnit, *toUnitsXY[2] = { toUnits[1], toUnits[2] };
54 if( ( dists->
Ws = (
double *)
smr_malloc2( smr, W_XYs->
length *
sizeof(
double ), 1,
"dists->Ws" ) ) == NULL )
goto err;
57 for( i = 0; i < W_XYs->
length; i++ ) {
58 XYs = &(W_XYs->
XYs[i]);
59 dists->
Ws[i] = wUnitFactor * XYs->
value;
64 else if( std::fabs( 1. - norm ) > 0.99 ) {
101 if( ( dist->
Xs = (
double *)
smr_malloc2( smr, 3 * n1 *
sizeof(
double ), 0,
"dist->Xs" ) ) == NULL )
goto err;
102 dist->
pdf = &(dist->
Xs[n1]);
103 dist->
cdf = &(dist->
pdf[n1]);
105 for( j1 = 0; j1 < n1; j1++ ) {
107 dist->
Xs[j1] = point->
x;
108 dist->
pdf[j1] = point->
y;
117 double inv_norm,
sum = 0;
119 inv_norm = 1.0 / ( dist->
Xs[n1-1] - dist->
Xs[0] );
120 for( j1 = 0; j1 < n1; ++j1 ) {
121 if( j1 > 0 ) sum += dist->
Xs[j1] - dist->
Xs[j1-1];
123 dist->
cdf[j1] = sum * inv_norm;
125 dist->
cdf[n1-1] = 1.; }
128 for( j1 = 0; j1 < n1; j1++ ) dist->
pdf[j1] /= *norm;
171 #if defined __cplusplus
ptwXPoints * ptwX_free(ptwXPoints *ptwX)
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int64_t ptwXY_length(ptwXYPoints *ptwXY)
enum ptwXY_interpolation_e ptwXY_interpolation
int MCGIDI_fromTOM_interpolation(statusMessageReporting *smr, xDataTOM_element *element, int index, enum ptwXY_interpolation_e *interpolation)
int MCGIDI_fromTOM_pdfsOfXGivenW(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_pdfsOfXGivenW *dists, ptwXYPoints *norms, char const *toUnits[3])
int MCGIDI_fromTOM_pdfOfX(statusMessageReporting *smr, ptwXYPoints *pdfXY, MCGIDI_pdfOfX *dist, double *norm)
ptwXYPoints * MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_XYs *XYs, ptwXY_interpolation interpolation, char const *units[2])
ptwXPoints * ptwXY_runningIntegral(ptwXYPoints *ptwXY, nfu_status *status)
double ptwX_getPointAtIndex_Unsafely(ptwXPoints *ptwX, int64_t index)
xDataTOM_interpolationQualifier
xDataTOM_xDataInfo xDataInfo
void * xDataTOME_getXDataIfID(statusMessageReporting *smr, xDataTOM_element *TE, char const *ID)
int xDataTOME_getInterpolation(statusMessageReporting *smr, xDataTOM_element *element, int index, enum xDataTOM_interpolationFlag *independent, enum xDataTOM_interpolationFlag *dependent, enum xDataTOM_interpolationQualifier *qualifier)
ptwXY_interpolation interpolationWY
#define smr_malloc2(smr, size, zero, forItem)
int smr_isOk(statusMessageReporting *smr)
enum nfu_status_e nfu_status
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define smr_setReportError2p(smr, libraryID, code, fmt)
void * smr_freeMemory(void **p)
ptwXY_interpolation interpolationXY
static int MCGIDI_fromTOM_pdfOfXGivenW(statusMessageReporting *smr, ptwXYPoints *pdfXY, MCGIDI_pdfsOfXGivenW *dists, int i, double *norm)
ptwXYPoint * ptwXY_getPointAtIndex_Unsafely(ptwXYPoints *ptwXY, int64_t index)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
nfu_status ptwXY_simpleCoalescePoints(ptwXYPoints *ptwXY)
const char * nfu_statusMessage(nfu_status status)
xDataTOM_interpolationFlag
nfu_status ptwXY_setValueAtX(ptwXYPoints *ptwXY, double x, double y)
char const * xDataTOM_axes_getUnit(statusMessageReporting *smr, xDataTOM_axes *axes, int index)