ocmath_init_linear_fit_options

 

Description

Function to set default options to LROptions structure for simple linear regression.

Syntax

void ocmath_init_linear_fit_options( LROptions * psLROptions )

Parameters

psLROptions
[Output] pointer to struct for linear regression options.

Return

Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.

Examples

EX1

//Import \Samples\Curve Fitting\Linear Fit.dat
void ocmath_init_linear_fit_options_ex()
{    
    Worksheet wks=Project.ActiveLayer();
    if(!wks)
                printf("no active worksheet found\n");
    Dataset dsSrcX(wks,0);
    Dataset dsSrcY(wks,1);    
    int nSize = dsSrcX.GetSize();
    
    FitParameter sFitParameter[2];
    LROptions sLROptions; 
    RegStats sRegStats;
    ocmath_init_linear_fit_options(&sLROptions);
    ocmath_linear_fit(dsSrcX, dsSrcY, nSize, sFitParameter, NULL, nSize, &sLROptions, &sRegStats);   
    printf("\nintercept = %6.4f\n", sFitParameter[0].Value);
    printf("standard error of intercept = %6.4f\n",sFitParameter[0].Error);         
    printf("slope = %6.4f\n", sFitParameter[1].Value);
    printf("standard error of slope = %6.4f\n", sFitParameter[1].Error);    
    printf("rsquare = %6.4f\n\n", sRegStats.RSqCOD);   
}

Remark

See Also

ocmath_linear_fit

header to Include

origin.h

Reference