Click or drag to resize
sqx

SQXMeanVarVectors Method

Procedure MeanVarVectors [nvarchar](max) @Query, [bit] @Population, [bit] @SnapShot, [Vector] Means, [Vector] Vars

Namespace:  sqx
Assembly:  SQX (in SQX.dll) Version: 1.0.2.6 (1.0.2.6)
Syntax
C#
public static int MeanVarVectors(
	SqlChars Query,
	SqlBoolean Population,
	SqlBoolean SnapShot,
	out Vector Means,
	out Vector Vars
)

Parameters

Query
Type: System.Data.SqlTypesSqlChars
[nvarchar](max)
Population
Type: System.Data.SqlTypesSqlBoolean
[bit]
SnapShot
Type: System.Data.SqlTypesSqlBoolean
[bit] 0 Read Commited | 1 SnapShot
Means
Type: sqxVector
[Vector] Output
Vars
Type: sqxVector
[Vector] Output

Return Value

Type: Int32
[int] 0 success | -1 failure
Remarks
High performance Means and Variances Vectors procedure.

NOTE: Query must return a dataset with only columns with numeric data type.
NOTE: CTE not available in @Query parameter.
Examples
SQL
declare @Query nvarchar(max) = N'
select a.Value [1],b.Value [2],c.Value [3]
from sqx.VectorTable(sqx.RandomVector(10,1)) a
inner join sqx.VectorTable(sqx.RandomVector(10,2)) b ON a.ID = b.ID
inner join sqx.VectorTable(sqx.RandomVector(10,3)) c ON a.ID = c.ID
'
declare @M sqx.Vector, @V sqx.Vector
exec sqx.MeanVarVectors @Query = @Query, @Population = 1, @SnapShot = 0
, @Means = @M OUTPUT, @Vars = @V OUTPUT
select m.ID, m.Value Mean, v.Value Variance 
from sqx.VectorTable(@M) m
inner join sqx.VectorTable(@V) v on m.ID = v.ID
/*
ID          Mean                   Variance
----------- ---------------------- ----------------------
1           0.472999690693337      0.0709172334310987
2           0.422586420468328      0.0968632683853888
3           0.472173150243318      0.0703461206094948*/
See Also