⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myrand.java

📁 用java实现的神经网络bp的核心算法
💻 JAVA
字号:
/*
 * MyRand.java
 *
 * Created on 2007年11月17日, 上午5:06
 *
 */

package myUtil;
import java.util.*;
/**
 * some customed random methord.
 * @author yuhui_bear
 */
public class MyRand {
    private ArrayList<NumberBox> st;
    /**
     * Creates a new instance of MyRand
     */
    public MyRand(int formin) {
        st = new ArrayList();
        for ( int  i= 0 ; i< formin;i++){
            st.add(new NumberBox(i));
        }
    }
    /**
     * generate a group of length n from  range from.
     * @param n ,length of the choosing group.
     * @return the new random sequence.
     */
    public int[] randSequence(int n){
        Random myrand = new Random();
        ArrayList<NumberBox> tlist = (ArrayList<NumberBox>)st.clone();
        int[] temp = new int[n];
        int t=0;
        for ( int k = 0 ; k < n; k++){
            t= myrand.nextInt(tlist.size());
            temp[k] =tlist.get(t).intData;
            tlist.remove(t);
        }        
        return temp;
    }  
    
    /**
     * generate a group of length n from  range from.
     * @param n ,length of the choosing group.
     * @param from , number range to choose.
     * @return the new random sequence.
     */
    public static int[] randSequence(int n , int from){
        Random myrand = new Random();
        int[] temp = new int[n];
        ArrayList<NumberBox> st = new ArrayList();
        int t=0;
        for ( int  i= 0 ; i< from;i++){
            st.add(new NumberBox(i));
        }
        for ( int k = 0 ; k < n; k++){
            t= myrand.nextInt(st.size());
            temp[k] =st.get(t).intData;
            st.remove(t);
        }
        
        return temp;
    }  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -