IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 793


Ignore:
Timestamp:
May 26, 2004, 4:49:34 PM (22 years ago)
Author:
gusciora
Message:

Coded the psGaussianDev() function.

Location:
trunk/psLib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psFunctions.c

    r774 r793  
    1616#include "float.h"
    1717#include <math.h>
    18 #define PI 3.14
     18#include <gsl/gsl_rng.h>
     19#include <gsl/gsl_randist.h>
    1920/*****************************************************************************
    2021    Evaluate a non-normalized Gaussian with the given mean and sigma at the
     
    3132
    3233    if (normal == 1) {
    33         tmp = 1.0 / sqrtf(2.0 * PI * (stddev * stddev));
     34        tmp = 1.0 / sqrtf(2.0 * M_PI * (stddev * stddev));
    3435        return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev)));
    3536    } else {
     
    3839}
    3940
    40 /*
     41/*****************************************************************************
     42    psGaussianDev()
     43 
     44 This routine creates a psVector of the specified size and type F32
     45 and fils it with a random Gaussiang distribution of numbers with
     46 the specified meand and sigma.  This routine makes use of the GSL
     47 routines for generating both uniformly distributed numbers and the
     48 Gaussian distribution as well.
     49 *****************************************************************************/
    4150psVector *psGaussianDev(float mean,
    4251                        float sigma,
     
    4453{
    4554    psVector *gauss = NULL;
    46  
     55    const gsl_rng_type *T = NULL;
     56    gsl_rng *r = NULL;
     57    int i = 0;
     58
    4759    gauss = psVectorAlloc(Npts, PS_TYPE_FLOAT);
    48 }
    49 */
     60    gsl_rng_env_setup();
     61    T = gsl_rng_default;
     62    r = gsl_rng_alloc(T);
     63
     64    for (i = 0; i < Npts; i++) {
     65        gauss->vec.f[i] = mean + gsl_ran_gaussian(r, sigma);
     66    }
     67    return(gauss);
     68}
     69
    5070
    5171/*****************************************************************************
  • trunk/psLib/src/math/psPolynomial.c

    r774 r793  
    1616#include "float.h"
    1717#include <math.h>
    18 #define PI 3.14
     18#include <gsl/gsl_rng.h>
     19#include <gsl/gsl_randist.h>
    1920/*****************************************************************************
    2021    Evaluate a non-normalized Gaussian with the given mean and sigma at the
     
    3132
    3233    if (normal == 1) {
    33         tmp = 1.0 / sqrtf(2.0 * PI * (stddev * stddev));
     34        tmp = 1.0 / sqrtf(2.0 * M_PI * (stddev * stddev));
    3435        return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev)));
    3536    } else {
     
    3839}
    3940
    40 /*
     41/*****************************************************************************
     42    psGaussianDev()
     43 
     44 This routine creates a psVector of the specified size and type F32
     45 and fils it with a random Gaussiang distribution of numbers with
     46 the specified meand and sigma.  This routine makes use of the GSL
     47 routines for generating both uniformly distributed numbers and the
     48 Gaussian distribution as well.
     49 *****************************************************************************/
    4150psVector *psGaussianDev(float mean,
    4251                        float sigma,
     
    4453{
    4554    psVector *gauss = NULL;
    46  
     55    const gsl_rng_type *T = NULL;
     56    gsl_rng *r = NULL;
     57    int i = 0;
     58
    4759    gauss = psVectorAlloc(Npts, PS_TYPE_FLOAT);
    48 }
    49 */
     60    gsl_rng_env_setup();
     61    T = gsl_rng_default;
     62    r = gsl_rng_alloc(T);
     63
     64    for (i = 0; i < Npts; i++) {
     65        gauss->vec.f[i] = mean + gsl_ran_gaussian(r, sigma);
     66    }
     67    return(gauss);
     68}
     69
    5070
    5171/*****************************************************************************
  • trunk/psLib/src/math/psSpline.c

    r774 r793  
    1616#include "float.h"
    1717#include <math.h>
    18 #define PI 3.14
     18#include <gsl/gsl_rng.h>
     19#include <gsl/gsl_randist.h>
    1920/*****************************************************************************
    2021    Evaluate a non-normalized Gaussian with the given mean and sigma at the
     
    3132
    3233    if (normal == 1) {
    33         tmp = 1.0 / sqrtf(2.0 * PI * (stddev * stddev));
     34        tmp = 1.0 / sqrtf(2.0 * M_PI * (stddev * stddev));
    3435        return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev)));
    3536    } else {
     
    3839}
    3940
    40 /*
     41/*****************************************************************************
     42    psGaussianDev()
     43 
     44 This routine creates a psVector of the specified size and type F32
     45 and fils it with a random Gaussiang distribution of numbers with
     46 the specified meand and sigma.  This routine makes use of the GSL
     47 routines for generating both uniformly distributed numbers and the
     48 Gaussian distribution as well.
     49 *****************************************************************************/
    4150psVector *psGaussianDev(float mean,
    4251                        float sigma,
     
    4453{
    4554    psVector *gauss = NULL;
    46  
     55    const gsl_rng_type *T = NULL;
     56    gsl_rng *r = NULL;
     57    int i = 0;
     58
    4759    gauss = psVectorAlloc(Npts, PS_TYPE_FLOAT);
    48 }
    49 */
     60    gsl_rng_env_setup();
     61    T = gsl_rng_default;
     62    r = gsl_rng_alloc(T);
     63
     64    for (i = 0; i < Npts; i++) {
     65        gauss->vec.f[i] = mean + gsl_ran_gaussian(r, sigma);
     66    }
     67    return(gauss);
     68}
     69
    5070
    5171/*****************************************************************************
Note: See TracChangeset for help on using the changeset viewer.