LinearPolarization ( )

Function stats

Average user rating
57
136
9999
Support
FileMaker 8.0 +
Date posted
11 December 2008
Last updated
11 December 2008
Version
Recursive function
No

Author Info
 Andries Heylen

6 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

LinearPolarization  ( _xValues;   _yValues;   _xPolarise )


Parameters

_xValues  List of X-values


_yValues  List of Y-values


_xPolarise  X value that you want to polarise


Description

Tags:  Regression   Predict   Polarisation   Linear  

Given a dataset ( { X1 ; Y1 } ; { X2 ; Y2} ; ... ; { Xn ; Yn} ) , this function will return an approximation of value Ym for Xm, based on linear regression ( see also function: LinearTrend: http://www.fmcustomfunctions.com/fid/135 ).

Examples

Sample input

_yValues = List ( 100 ; 150 ; 200 ; 400 ; 200 ; 200 ; 200 ; 100 ; 300 )
_xValues = List ( 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 )
_xPolarise = 16


Sample output

308,3

 

Function code

/*
Given a dataset ( { X1 ; Y1 } ; { X2 ; Y2} ; ... ; { Xn ; Yn} ) , this function will return a predicted value Ym for Xm, based on linear regression ( see also function: LinearTrend: http://www.fmcustomfunctions.com/fid/135 ).

Developped by : Andries Heylen [BH&A]
mail: andries_heylen@bh-a.com

v1.0 08/12/2008 Andries Heylen [BH&A]

Example:

input:

_yValues = List ( 100 ; 150 ; 200 ; 400 ; 200 ; 200 ; 200 ; 100 ; 300 )
_xValues = List ( 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 )
_xPolarise = 16

returns:

308,3 (predicted value for Xm = 16 )

Function uses:

CustomList by Agnes:
http://www.fmcustomfunctions.com/fid/118

*/


Let (
[
$listY = _yValues
; _Nmb = ValueCount ( $ListY )
; $listX = _xValues
; _SerieX = Substitute ( $listX ; ¶ ; ";" )
; _SumX = Evaluate ( "Sum ( " & _SerieX & ")" )
; _SerieY = Substitute ( $listY ; ¶ ; ";" )
; _SumY = Evaluate ( "Sum ( " & _SerieY & ")" )
; _ListXY = CustomList ( 1 ; _Nmb ; "GetValue ( $ListX ; [n] ) * GetValue ( $ListY ; [n] )" )
; _SerieXY = Substitute ( _ListXY ; ¶ ; ";" )
; _SumXY = Evaluate ( "Sum ( " & _SerieXY & " ) " )
; _ListX2 = CustomList ( 1 ; _Nmb ; "GetValue ( $ListX ; [n] ) ^ 2" )
; _SerieX2 = Substitute ( _ListX2 ; ¶ ; ";" )
; _SumX2 = Evaluate ( "Sum ( " & _SerieX2 & " ) " )
; _b = Round ( ( _Nmb * _SumXY - _SumX * _SumY ) / ( _Nmb * _SumX2 - _SumX ^2 ) ; 2 )
; _a = Round ( ( _SumY - _b * _SumX ) / _Nmb ; 2 )
]
;
_a + _b * _XPolarise


)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/136

    Prototype: LinearPolarization( _xValues; _yValues; _xPolarise )
    Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)
    Last updated: 11 December 2008
    Version: 1.1

*/
// ===================================

 

 

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.