source: sasview/sansmodels/src/sans/models/c_extensions/logNormal.c @ 20f00bed

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 20f00bed was eba9885, checked in by Gervaise Alina <gervyh@…>, 15 years ago

code for evalDistribution

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[eba9885]1/**
2 * log normal function
3 */
4
5#include "logNormal.h"
6#include <math.h>
7#include <stdio.h>
8#include <stdlib.h>
9
10
11/**
12 * Function to evaluate 1D Log normal function.
13 * The function is normalized to the 'scale' parameter.
14 *
15 * f(x)=scale * 1/(sigma*math.sqrt(2pi))e^(-1/2*((math.log(x)-mu)/sigma)^2)
16 *
17 * @param pars: parameters of the log normal
18 * @param x: x-value
19 * @return: function value
20 */
21double logNormal_analytical_1D(LogNormalParameters *pars, double x) {
22        double sigma2 = pow(pars->sigma, 2);   
23        return pars->scale / (x*sigma2) * exp( -pow((log(x) -pars->center), 2) / (2*sigma2));
24}
25
26/**
27 * Function to evaluate 2D log normal  function
28 * The function is normalized to the 'scale' parameter.
29 *
30 * f(x,y) = LogNormal(x) * Lognormal(y)
31 *
32 * where both Gaussians share the same parameters.
33 *
34 * @param pars: parameters of the log normal
35 * @param x: x-value
36 * @param y: y-value
37 * @return: function value
38 */
39double logNormal_analytical_2DXY(LogNormalParameters *pars, double x, double y) {
40    return logNormal_analytical_1D(pars, x) * logNormal_analytical_1D(pars, y);
41} 
42
43/**
44 * Function to evaluate 2D log normal  function
45 * The function is normalized to the 'scale' parameter.
46 *
47 * f(x,y) = Lognormal(x) * Lognormal(y)
48 *
49 * where both log normal s share the same parameters.
50 *
51 * @param pars: parameters of the log normal
52 * @param length: length of the (x,y) vector
53 * @param phi: angle relative to x
54 * @return: function value
55 */
56double logNormal_analytical_2D(LogNormalParameters *pars, double length, double phi) {
57    return logNormal_analytical_2DXY(pars, length*cos(phi), length*sin(phi));
58} 
Note: See TracBrowser for help on using the repository browser.