* - no subject -
@ 2011-05-27 9:17 sherry mikheal
0 siblings, 0 replies; only message in thread
From: sherry mikheal @ 2011-05-27 9:17 UTC (permalink / raw)
To: gsl-discuss
I am a student who is trying to use the histogram methods that were
published , but my problem is that i have tried to get the logarithmic
values of these histograms using these 2 methods :
first method for normalization :
Make continuous double probability density functions by appropriate
normalization
*/
template <typename T, typename V>
gsl_histogram** CHistogram<T,
V>::getContinuousDoubleProbabilityDensities()
{
int i;
if ( this->doubleHistograms != NULL ) {
// Clone histograms and normalize
if ( this->continuousDoubleProbabilityDensities == NULL ) {
this->continuousDoubleProbabilityDensities = new gsl_histogram*[
this->numberOfHistograms ];
for ( i = 0; i < this->numberOfHistograms; i++ ) {
this->continuousDoubleProbabilityDensities[ i ] =
gsl_histogram_clone( this->doubleHistograms[ i ] );
gsl_histogram_scale( this->continuousDoubleProbabilityDensities[ i
],
1.0 / ( gsl_histogram_sum(
this->continuousDoubleProbabilityDensities[ i ] )
* this->binWidth ) );
}
}
return this->continuousDoubleProbabilityDensities;
}
else {
this->printError( "getContinuousDoubleProbablilityDensities(),"
"No continuous double probability densities available!" );
return NULL;
}
}
second method to get log :
/*
* Get logarithmized continuous double probability density functions
*/
template <typename T, typename V>
gsl_histogram** CHistogram<T,
V>::getLogContinuousDoubleProbabilityDensities()
{
int i, j;
if ( this->doubleHistograms != NULL ) {
// Make continuous double probability density functions
if ( this->continuousDoubleProbabilityDensities == NULL ) {
getContinuousDoubleProbabilityDensities();
}
// Create histograms and logarithmize content
if ( this->logContinuousDoubleProbabilityDensities == NULL ) {
this->logContinuousDoubleProbabilityDensities = new
gsl_histogram*[ this->numberOfHistograms ];
for ( i = 0; i < this->numberOfHistograms; i++ ) {
this->logContinuousDoubleProbabilityDensities[ i ] =
gsl_histogram_alloc( this->numberOfBins );
gsl_histogram_set_ranges_uniform(
this->logContinuousDoubleProbabilityDensities[ i ],
this->minValue,
this->maxValue );
for ( j = 0; j < this->numberOfBins; j++ ) {
gsl_histogram_accumulate(
this->logContinuousDoubleProbabilityDensities[ i ],
this->minValue + ( j + 0.5 ) * this->binWidth,
log10( gsl_histogram_get(
this->continuousDoubleProbabilityDensities[ i ],
j ) ) );
//std::cout << "result new "
<<logContinuousDoubleProbabilityDensities<<std::endl;
}
}
}
return this->logContinuousDoubleProbabilityDensities;
}
else {
this->printError( "getLogContinuousDoubleProbabilityDensities()",
"No logarithmized continuous double probability densities
available!" );
return NULL;
}
}
/*
* Get logarithmized continuous complex probability density functions
*/
template <typename T, typename V>
gsl_histogram2d** CHistogram<T,
V>::getLogContinuousComplexProbabilityDensities()
{
int i, j, k;
if ( this->complexHistograms != NULL ) {
// Make discrete complex probability density functions
if ( this->discreteComplexProbabilityDensities == NULL ) {
getDiscreteComplexProbabilityDensities();
}
// Create histograms and logarithmize content
if ( this->logDiscreteComplexProbabilityDensities == NULL ) {
this->logDiscreteComplexProbabilityDensities = new
gsl_histogram2d*[ this->numberOfHistograms ];
for ( i = 0; i < this->numberOfHistograms; i++ ) {
this->logDiscreteComplexProbabilityDensities[ i ] =
gsl_histogram2d_alloc( this->numberOfBins,
this->numberOfBins );
gsl_histogram2d_set_ranges_uniform(
this->logDiscreteComplexProbabilityDensities[ i ],
this->minValue,
this->maxValue,
this->minValue,
this->maxValue );
for ( j = 0; j < this->numberOfBins; j++ ) {
for ( k = 0; k < this->numberOfHistograms; k++ ) {
gsl_histogram2d_accumulate(
this->logDiscreteComplexProbabilityDensities[ i ],
this->minValue + ( j + 0.5 ) * this->binWidth,
this->minValue + ( k + 0.5 ) * this->binWidth,
log10( gsl_histogram2d_get(
this->discreteComplexProbabilityDensities[ i ],
j,
k ) ) );
}
}
}
}
return this->logDiscreteComplexProbabilityDensities;
}
else {
this->printError( "getLogDiscreteComplexProbabilityDensities()",
"No logarithmized discrete complex probability densities
available!" );
return NULL;
}
}
but then he results of the histogram are either negative infinty (which
is ok ) or positive values which is not ok as my probabilities should
range between negative infinity and zero after getting log ....so any
idea about this ,please help
Best Regards ,
Sherry
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-27 9:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-27 9:17 - no subject - sherry mikheal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).