public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: sherry mikheal <mikheal@inue.uni-stuttgart.de>
To: gsl-discuss@sourceware.org
Subject: - no subject -
Date: Fri, 27 May 2011 09:17:00 -0000	[thread overview]
Message-ID: <15310053.311306485364274.OPEN-XCHANGE.WebMail.tomcat@inupc4.inue.uni-stuttgart.de> (raw)


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 

                 reply	other threads:[~2011-05-27  9:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15310053.311306485364274.OPEN-XCHANGE.WebMail.tomcat@inupc4.inue.uni-stuttgart.de \
    --to=mikheal@inue.uni-stuttgart.de \
    --cc=gsl-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).