Special functions |
Top |
There are a number of special functions which you can use when creating formulas. They are divided in the categories: random numbers, statistical functions, mathematical functions, and logical functions
Random numbers In all sorts of situations, for example if a random sample is drawn, it can be helpful to have random numbers at your disposal. VUstat knows the following ways of generating random numbers:
bernouilli(p) generates the value 0 with probability p and the value 1 with probability 1-p exponential(number) generates values from the exponential distribution with expected value number norm(mean;sd) generates values from the normal distribution with mean mean and standard deviation sd poisson(number) generates values from a Poisson distribution with lambda=number, provided number>0 random(number) generates integer values between 0 and number. If number=0 values between 0 and 1 are generated. uniform(number) generates values between 0 and number.
Statistical functions The following statistical functions can also be used in the creation of formulas. @mean([variable]) calculates the mean of a column. @squaresum([variable]) calculates the sum of the squares of all observations in one column @max([variable]) selects the maximum value in a column @min([variable]) selects the minimal value in a column. @sd([variable]) calculates the standard deviation of the values in a column. @sum([variable]) calculates the sum of all of the observations in a column @count([variable]) count the number of observations in a column @var([variabele]) calculates the variance of the values in a column @z([variable]) calculates the standard normal values of the values in a column.
Mathematical functions The following mathematical functions can be used with the creation of formulas. abs([variable]) calculates the absolute value. Example: abs(-5)=5 and abs(7.5)=7.5. cos([variable]) calculates the cosine, the value of the variable is in radians exp([variable]) the exponential function. int([variable]) the integer-function. Example: int(5.5)=5, int(5.9)=5, int(-5.9)=-6. log([variable]) calculates the log to base 10 of a number ln([variable]) calculates the natural logarithm, base e max([variable]) calculates the maximum of any sequence of numbers Example: max([var1],[var2],[var3]) gives the maximum of the three numbers var1, var2, var3 min([variable]) calculates the minimum of a series of numbers Example: min([var1],[var2],[var3]) gives the minimum of the three variables var1, var2, var3 if the if-then function The if–then function, has the format: if(a,b,c). It has three arguments: a, b and c. The first argument (a) is an expression which can be true or false The second argument (b) is the result if the first argument (a) is true. The third argument (c ) is the result if the first argument (a) is false. Example: if([length]<170, 1, 2). If [length] = 154 then the value is 1 and if [length]=183 then the value is 2. and the and-function only appears as part of the if function. Example: if([income]<100 and [work]>50; 0 ; 1) not the not-function only appears as part of the if-then. Example: if (not [income]<100, b, c). or the or-function only appears as part of the if-then function Example: if([income]<100 or [work]>50, b, c).
sgn([variable]) the sign-function gives information about the sign of the function. The sgn-function gives with positive numbers as result a 1, with negative numbers the value -1 and sgn(0)=0
sin([variable]) calculates the sine, the value of variable is in radians sqr([variable]) calculates the square of a number Example: sqr(5)=25. sqrt([variable]) calculates the root of a number. Example: sqrt(16)=4. tan([variable]) calculates the tangent, value variable in radians
Logical functions AND a AND b says that both a and b must be true OR a OR b says that a or b (or both) must be true.
|