Skip to main content

Posts

Showing posts with the label mode

Mode Component (class) in Coldfusion

In statistics, the mode is the value that occurs the most frequently in a data set or a probability distribution. In some fields, notably education, sample data are often called scores, and the sample mode is known as the modal score. [1] The code below will find the mode value in a non sorted array. Save the below component with the name mode.cfc in a directory under wwwroot, in my case I save my components in a directory called classes: <cfcomponent> <cffunction name="getMode" access="public" returntype="string"> <cfargument name="amode" type="array" required="true"> <cfset oldcount=0><cfset oldtemp=0> <cfloop from="1" to="#arrayLen(amode)-1#" index="i"> <cfset temp=amode[i]> <cfset count=1> <cfloop from="#i+1#" to="#arrayLen(amode)-1#" index="j"> <cfif temp i...