📄 utils.html
字号:
<DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double<DD><CODE>b</CODE> - a double</DL></DD></DL><HR><A NAME="log2(double)"><!-- --></A><H3>log2</H3><PRE>public static double <B>log2</B>(double a)</PRE><DL><DD>Returns the logarithm of a for base 2.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - a double</DL></DD></DL><HR><A NAME="maxIndex(double[])"><!-- --></A><H3>maxIndex</H3><PRE>public static int <B>maxIndex</B>(double[] doubles)</PRE><DL><DD>Returns index of maximum element in a given array of doubles. First maximum is returned.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>doubles</CODE> - the array of doubles<DT><B>Returns:</B><DD>the index of the maximum element</DL></DD></DL><HR><A NAME="maxIndex(int[])"><!-- --></A><H3>maxIndex</H3><PRE>public static int <B>maxIndex</B>(int[] ints)</PRE><DL><DD>Returns index of maximum element in a given array of integers. First maximum is returned.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>ints</CODE> - the array of integers<DT><B>Returns:</B><DD>the index of the maximum element</DL></DD></DL><HR><A NAME="mean(double[])"><!-- --></A><H3>mean</H3><PRE>public static double <B>mean</B>(double[] vector)</PRE><DL><DD>Computes the mean for an array of doubles.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>vector</CODE> - the array<DT><B>Returns:</B><DD>the mean</DL></DD></DL><HR><A NAME="minIndex(int[])"><!-- --></A><H3>minIndex</H3><PRE>public static int <B>minIndex</B>(int[] ints)</PRE><DL><DD>Returns index of minimum element in a given array of integers. First minimum is returned.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>ints</CODE> - the array of integers<DT><B>Returns:</B><DD>the index of the minimum element</DL></DD></DL><HR><A NAME="minIndex(double[])"><!-- --></A><H3>minIndex</H3><PRE>public static int <B>minIndex</B>(double[] doubles)</PRE><DL><DD>Returns index of minimum element in a given array of doubles. First minimum is returned.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>doubles</CODE> - the array of doubles<DT><B>Returns:</B><DD>the index of the minimum element</DL></DD></DL><HR><A NAME="normalize(double[])"><!-- --></A><H3>normalize</H3><PRE>public static void <B>normalize</B>(double[] doubles)</PRE><DL><DD>Normalizes the doubles in the array by their sum.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>doubles</CODE> - the array of double<DT><B>Throws:</B><DD><CODE>java.lang.IllegalArgumentException</CODE> - if sum is Zero or NaN</DL></DD></DL><HR><A NAME="normalize(double[], double)"><!-- --></A><H3>normalize</H3><PRE>public static void <B>normalize</B>(double[] doubles, double sum)</PRE><DL><DD>Normalizes the doubles in the array using the given value.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>doubles</CODE> - the array of double<DD><CODE>sum</CODE> - the value by which the doubles are to be normalized<DT><B>Throws:</B><DD><CODE>java.lang.IllegalArgumentException</CODE> - if sum is zero or NaN</DL></DD></DL><HR><A NAME="logs2probs(double[])"><!-- --></A><H3>logs2probs</H3><PRE>public static double[] <B>logs2probs</B>(double[] a)</PRE><DL><DD>Converts an array containing the natural logarithms of probabilities stored in a vector back into probabilities. The probabilities are assumed to sum to one.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>a</CODE> - an array holding the natural logarithms of the probabilities<DT><B>Returns:</B><DD>the converted array</DL></DD></DL><HR><A NAME="round(double)"><!-- --></A><H3>round</H3><PRE>public static int <B>round</B>(double value)</PRE><DL><DD>Rounds a double to the next nearest integer value. The JDK version of it doesn't work properly.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>value</CODE> - the double value<DT><B>Returns:</B><DD>the resulting integer value</DL></DD></DL><HR><A NAME="probRound(double, java.util.Random)"><!-- --></A><H3>probRound</H3><PRE>public static int <B>probRound</B>(double value, java.util.Random rand)</PRE><DL><DD>Rounds a double to the next nearest integer value in a probabilistic fashion (e.g. 0.8 has a 20% chance of being rounded down to 0 and a 80% chance of being rounded up to 1). In the limit, the average of the rounded numbers generated by this procedure should converge to the original double.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>value</CODE> - the double value<DT><B>Returns:</B><DD>the resulting integer value</DL></DD></DL><HR><A NAME="roundDouble(double, int)"><!-- --></A><H3>roundDouble</H3><PRE>public static double <B>roundDouble</B>(double value, int afterDecimalPoint)</PRE><DL><DD>Rounds a double to the given number of decimal places.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>value</CODE> - the double value<DD><CODE>afterDecimalPoint</CODE> - the number of digits after the decimal point<DT><B>Returns:</B><DD>the double rounded to the given precision</DL></DD></DL><HR><A NAME="sort(int[])"><!-- --></A><H3>sort</H3><PRE>public static int[] <B>sort</B>(int[] array)</PRE><DL><DD>Sorts a given array of integers in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array. The sort is stable. (Equal elements remain in their original order.)<P><DD><DL><DT><B>Parameters:</B><DD><CODE>array</CODE> - this array is not changed by the method!<DT><B>Returns:</B><DD>an array of integers with the positions in the sorted array.</DL></DD></DL><HR><A NAME="sort(double[])"><!-- --></A><H3>sort</H3><PRE>public static int[] <B>sort</B>(double[] array)</PRE><DL><DD>Sorts a given array of doubles in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array. NOTE THESE CHANGES: the sort is no longer stable and it doesn't use safe floating-point comparisons anymore. Occurrences of Double.NaN are treated as Double.MAX_VALUE<P><DD><DL><DT><B>Parameters:</B><DD><CODE>array</CODE> - this array is not changed by the method!<DT><B>Returns:</B><DD>an array of integers with the positions in the sorted array.</DL></DD></DL><HR><A NAME="stableSort(double[])"><!-- --></A><H3>stableSort</H3><PRE>public static int[] <B>stableSort</B>(double[] array)</PRE><DL><DD>Sorts a given array of doubles in ascending order and returns an array of integers with the positions of the elements of the original array in the sorted array. The sort is stable (Equal elements remain in their original order.) Occurrences of Double.NaN are treated as Double.MAX_VALUE<P><DD><DL><DT><B>Parameters:</B><DD><CODE>array</CODE> - this array is not changed by the method!<DT><B>Returns:</B><DD>an array of integers with the positions in the sorted array.</DL></DD></DL><HR><A NAME="variance(double[])"><!-- --></A><H3>variance</H3><PRE>public static double <B>variance</B>(double[] vector)</PRE><DL><DD>Computes the variance for an array of doubles.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>vector</CODE> - the array<DT><B>Returns:</B><DD>the variance</DL></DD></DL><HR><A NAME="sum(double[])"><!-- --></A><H3>sum</H3><PRE>public static double <B>sum</B>(double[] doubles)</PRE><DL><DD>Computes the sum of the elements of an array of doubles.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>doubles</CODE> - the array of double<DT><B>Returns:</B><DD>the sum of the elements</DL></DD></DL><HR><A NAME="sum(int[])"><!-- --></A><H3>sum</H3><PRE>public static int <B>sum</B>(int[] ints)</PRE><DL><DD>Computes the sum of the elements of an array of integers.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>ints</CODE> - the array of integers<DT><B>Returns:</B><DD>the sum of the elements</DL></DD></DL><HR><A NAME="xlogx(int)"><!-- --></A><H3>xlogx</H3><PRE>public static double <B>xlogx</B>(int c)</PRE><DL><DD>Returns c*log2(c) for a given integer value c.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - an integer value<DT><B>Returns:</B><DD>c*log2(c) (but is careful to return 0 if c is 0)</DL></DD></DL><HR><A NAME="main(java.lang.String[])"><!-- --></A><H3>main</H3><PRE>public static void <B>main</B>(java.lang.String[] ops)</PRE><DL><DD>Main method for testing this class.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>ops</CODE> - some dummy options</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../Tutorial.pdf"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="http://www.cs.waikato.ac.nz/ml/weka/index.html"><FONT CLASS="NavBarFont1"><B>Weka's home</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../weka/core/Tag.html" title="class in weka.core"><B>PREV CLASS</B></A> <A HREF="../../weka/core/Version.html" title="class in weka.core"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="Utils.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -