Changeset 0ad5703 in sasview for sansmodels/src


Ignore:
Timestamp:
Mar 24, 2011 4:11:05 PM (13 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
389c991
Parents:
50764a4
Message:

PD correction on lognormal distribution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_models/parameters.cpp

    r59b9b675 r0ad5703  
    160160        npts  = 11; 
    161161        width = 0.0; 
    162         nsigmas = 1.0; 
     162        nsigmas = 1.73205; 
    163163}; 
    164164 
     
    172172double rectangle_weight(double mean, double sigma, double x) { 
    173173        double vary, expo_value; 
    174     double sig = fabs(sigma); 
    175     if (x>= (mean-sig) && x<(mean+sig)){ 
     174    double wid = fabs(sigma) * sqrt(3.0); 
     175    if (x>= (mean-wid) && x<=(mean+wid)){ 
    176176        return 1.0; 
    177177    } 
     
    193193                width = 0.0; 
    194194                npts  = 1; 
    195                 nsigmas = 1.0; 
     195                nsigmas = 1.73205; 
    196196        } 
    197197 
     
    228228 
    229229LogNormalDispersion :: LogNormalDispersion() { 
    230         npts  = 11; 
     230        npts  = 15; 
    231231        width = 0.0; 
    232         nsigmas = 3.0; 
     232        nsigmas = 4.0; 
    233233}; 
    234234 
     
    243243 
    244244        double sigma2 = pow(sigma, 2.0); 
    245         return 1.0/(x*sigma2) * exp( -pow((log(x) -mean), 2.0) / (2.0*sigma2)); 
     245        return 1.0/(x*sigma) * exp( -pow((log(x) -log(mean)), 2.0) / (2.0*sigma2)); 
    246246 
    247247} 
     
    259259                width = 0.0; 
    260260                npts  = 1; 
    261                 nsigmas = 3.0; 
     261                nsigmas = 4.0; 
    262262        } 
    263263 
     
    269269        } else { 
    270270                for(int i=0; i<npts; i++) { 
     271                        // Note that the definition of sigma is different from Gaussian 
    271272                        if ((*par).has_min==false){ 
    272                                 // width = sigma for angles 
     273                                // sig  for angles 
     274                                sig = width / value; 
     275                        } 
     276                        else{ 
     277                                // by lognormal definition, PD is same as sigma 
    273278                                sig = width; 
    274279                        } 
    275                         else{ 
    276                                 //width = polydispersity (=sigma/value) for length 
    277                                 sig = width * value; 
    278                         } 
     280 
    279281                        // We cover n(nsigmas) times sigmas on each side of the mean 
    280282                        double val = value + sig * (2.0*nsigmas*double(i)/double(npts-1) - nsigmas); 
Note: See TracChangeset for help on using the changeset viewer.