You need to change the name of the field avg(test) to remove the parenthesis. However, first you need to make a change to the stats command portion of the search. To mitigate this issue, you can use the sigfig function to specify the number of significant figures you want returned. This occurs because numbers are treated as double-precision floating-point numbers. When the count is changed to 10000, the results are different: For example, the following search calculates the average of 100 values: Using the sigfig function, the final result is rounded to 3 digits, returning n=1110 and not 1111.Įxample 2: There are situations where the results of a calculation can return a different accuracy to the very far right of the decimal point. In this example, the minimum number of significant figures for all operands is 3. In this example, 1.00 has 3 significant figures and 1111 has 4 significant figures. The calculation 1.00*1111 returns the value n=1111, but the following search using the sigfig function returns n=1110. Because the number to the right of the last significant figure is greater than 5, the result returned is 127.6Įxample 1: The following example shows how the sigfig function works. In this example only one decimal place is returned. If the calculation is 123.0 + 4.567 = 127.567, then the sigfig function returns the fewest number of decimal places. The second number is more precise because it has 3 decimal places. The first number is less precise because it has 1 decimal place. For addition and subtraction, the result should have the same number of decimal places as the least precise number of all of the operands.įor example, the numbers 123.0 and 4.567 contain different precision with the decimal places.For multiplication and division, the result should have the minimum number of significant figures of all of the operands.The computation for sigfig is based on the type of calculation that generates the number. This function rounds a number to the appropriate number of significant figures. Because a is not specified, the number is rounded to the integer. You cannot specify a negative number for the precision.īasic examples Specifying a value without precision The precision is optional, and if omitted the round function rounds to an integer. This function returns a number rounded to the decimal places specified by the precision. This function returns a number to the power of the exponent. The following example calculates the area of a circle, which is pi() multiplied by the radius to the power of 2. This function takes no arguments and returns the constant ' pi to 11 digits of precision. The following example returns the logarithm of the numeric literal 100000, using base 10. The following example returns the logarithm of the values of the number field, using base 2. The base is optional, and if omitted the log function uses base 10. This function returns the logarithm of a number using a base. The following example returns the natural logarithm of the values in the bytes field. This function returns the natural logarithm of a number. This function rounds a number down to the nearest whole integer. This function returns the exponential function e X of a number. This function returns the result of a numeric eval calculation with a larger amount of precision in the formatted output.Ĭalculates the circumference of a set of circles by multiplying pi by the values in the diameter field. You can use the abbreviation ceil() instead of the full name of the function. This function rounds a number up to the next highest integer. WHERE mydata>abs(-10.95) ceiling() or ceil() In this example, the values in the mydata field are greater than the absolute value of the numeric literal -10.95. The following example uses the abs function in a WHERE clause. The following example creates a field called absnum, whose values are the absolute values of the numeric field number. You can use this function with the eval and where commands, in the WHERE clause of the from command, and as part of evaluation expressions with other commands. The argument can be the name of a numeric field or a numeric literal. This function returns the absolute value of a number. For the list of mathematical operators you can use with these functions, see the "Operators" section in eval command usage.For information about using string and numeric fields in functions, and nesting functions, see Overview of SPL2 eval functions.The following list contains the functions that you can use to perform mathematical calculations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |