`
ggyyleo
  • 浏览: 49678 次
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

assas

阅读更多
package com.jleo.pickitup;

import org.apache.commons.collections.list.TreeList;

import java.math.BigDecimal;
import java.util.*;

public class Norm{
	public static double normrnd(double mu, double sigma) {
		double N = 12;
		double x = 0, temp = N;
		do {
			x = 0;
			for (int i = 0; i < N; i++)
				x = x + (Math.random());
			x = (x - temp / 2) / (Math.sqrt(temp / 12));
			x = mu + x * Math.sqrt(sigma);
		} while (x <= 0);
		return x;
	}

	public static double[] addInv(double[] r) {
		double[] result = new double[r.length * 2];
		for (int i = 0; i < result.length; i += 2) {
			result[i] = r[i / 2];
			result[i + 1] = -r[i / 2];
		}
		return result;
	}

	public static double[] normrnd(double sigma, int num) {
		double[] r = new double[num];
		for (int i = 0; i < num; i++) {
			r[i] = normrnd(0, sigma);
		}
		return addInv(r);
	}

	public static Point[] generateMap(int x1, int x2, int y1, int y2, int numberOfDots,int numberOfBlock) {

		double mu = 3;
		double sigma = 1;

		int[] x = new int[numberOfDots];
		int[] y = new int[numberOfDots];
        int xDevideBy = (x2 - x1)/numberOfBlock;
        int yDevideBy = (y2 - y1)/numberOfBlock;

		Point[] points = new Point[numberOfDots];
		for (int i = 0; i < numberOfDots; i++) {
			x[i] = (int) ((normrnd(mu, sigma)-3)*((x2-x1)/6)+(x1+x2)/2);
			y[i] = (int) ((normrnd(mu, sigma)-3)*((y2-y1)/6)+(y1+y2)/2);
			points[i] = new Point(x[i], y[i], (x[i]-x1)/xDevideBy,(y[i]-y1)/yDevideBy);
		}
		return points;
	}

    public static String[] getNeighbours(String zoneId){
        int zonex = Integer.valueOf(zoneId.split(",")[0]);
        int zoney = Integer.valueOf(zoneId.split(",")[1]);

        String[] neighbours = new String[9];
        int idx = 0;
        for(int x= zonex-1;x<=zonex+1;x++){
           for(int y= zoney-1;y<=zoney+1;y++){
                neighbours[idx] = x+","+y;
                idx++;
            }
        }
        return neighbours;
    }

	public static void main(String[] args) {
        int x1 = 31095278;
        int x2 = 31334871;
        int y1 = 121256104;
        int y2 = 121629639;
        int numberOfDots = 50000000;
        int numberOfBlock = 150;
        Point[] points = Norm.generateMap(x1, x2, y1, y2, numberOfDots, numberOfBlock);
        Map<String, List<Point>> blockMap = new HashMap<String, List<Point>>();
        for(int i=0; i<points.length; i++){
            Point p = points[i];
            String zoneId = p.zonex+","+p.zoney;

            if(!blockMap.containsKey(zoneId)){
                List<Point> ps = new ArrayList<Point>();
                ps.add(p);
                blockMap.put(zoneId,ps);
            } else{
                blockMap.get(zoneId).add(p);
            }
        }
        long t1 = System.currentTimeMillis();
        String zoneid = points[1245].zonex + "," + points[1245].zoney;

        String[] neighbours = getNeighbours(zoneid);
        List<Point> pointsInNeighbours = new ArrayList<Point>();
        for(int i=0;i<neighbours.length; i++){
             if(blockMap.containsKey(neighbours[i]))
                 pointsInNeighbours.addAll(blockMap.get(neighbours[i]));
        }
        TreeMap tm = new TreeMap();
        for(int i=0; i<pointsInNeighbours.size(); i++){
            if(pointsInNeighbours.get(i) == points[1245])
                continue;

            tm.put(points[1245].distanceTo(pointsInNeighbours.get(i)), pointsInNeighbours.get(i));

        }
        long t2 = System.currentTimeMillis();
        System.out.println(t2-t1);
        System.out.println(tm.firstKey());

         long t3 = System.currentTimeMillis();
        tm = new TreeMap();
        for(int i=0; i<points.length; i++){
            if(points[i] == points[1245])
                continue;

            tm.put(points[1245].distanceTo(points[i]), points[i]);

        }

        long t4 = System.currentTimeMillis();
        System.out.println(t4-t3);
        System.out.println(tm.firstKey());
	}
}
aas
分享到:
评论

相关推荐

    assas_integration:与Asaas付款API的基本集成。 在此存储库中,将可以将代码重新用于API所提供的自动例程或其他功能。

    在这个`assas_integration-master`压缩包中,可能包含了以下文件和目录: 1. `config.php` - 配置文件,存放API密钥、URL和其他设置。 2. `classes/` - 类库,封装了与Asaas API交互的函数或对象。 - `AsaasClient...

    通过JAVA、VB访问SAS IOM服务器

    Dim obSAS As SAS.Workspace Dim obWSMgr As New SASWorkspaceManager.WorkspaceManager Private Sub Form_Load() Dim XMLInfo As String ' create Workspace server Dim obServer As New SASWorkspaceManager....

    法国大学专业排名一览.doc

    2. **巴黎二大(Université Paris 2 Panthéon-Assas)**: - **商法与税务法专业**:与巴黎一大并驾齐驱,毕业生在业界有很高的需求。 - **企业财务与账目管理专业**:针对有一定知识和经验的专业人士,课程由...

    matlab说话代码-utl_download_2015_ACS_5yr_zipcode_level_american_community_s

    matlab说话代码utl_download_2015_ACS_5yr_zipcode_level_american_community_survey_demographics_as_sas_dataset 以sas数据集下载2015 ACS 5yr邮政编码级别的美国社区调查人口统计信息。 关键字:sas sql join合并...

    matlab转换java代码-utl_compounding_returns_over_months:数月复利。关键字:sassqljoin合

    matlab转换java代码utl_compounding_returns_over_months 数月复利。...as SAS Nice solution by Art Two Solutions 1. Art datastep WPS 2. K Sharp IML WPS see https://goo.gl/kBjfAU https://communitie

    Introduction to SAS and Hadoop

    Although not covered in any detail, a brief overview of additional SAS and Hadoop technologies, including DS2, high-performance analytics, SAS LASR Server, and in- memory Statistics, as well as the ...

    SAS_9.3 sid

    例如,“*PRODNUM000=BASEBaseSAS”表明基础的SAS功能是可用的,而“*PRODNUM001=STATSAS/STAT”则表示统计分析模块也是许可的。这种模块化的设计使得用户可以根据自己的需求选择不同的功能组合,从而实现更灵活的...

    和crackman学sas整理版

    从给定的文件信息中,我们可以提炼出关于SAS编程的几个重要知识点,涉及数据预处理、循环结构、文件读取、SQL应用等方面。以下是详细的知识点解析: ### SAS中的循环与文件读取 #### 1. 使用循环读取多个文件 在...

    006SAS SQL语言.pdf

    - **重命名列**:使用AS关键字。 - **格式和标签修改**:使用FORMAT和LABEL选项。 - **列的顺序**:SELECT中的顺序决定输出顺序。 #### 3. 对行的操作 - **DISTINCT关键字**:去除重复行。 - **WHERE从句**:结合...

    VB与SAS整合使用

    customize reports as they are run. The system allows the user to easily select many different parameters to be used to create a report without changing a single line of the SAS code in each report. ...

    SAS教程:Data Analysis Using SAS Enterprise Guide(英文版)

    Designed to be used either as a stand-alone resource or as an accompaniment to a statistics course, the book offers a smooth path to statistical analysis with SAS Enterprise Guide for advanced ...

    Biostatistics by Example Using SAS Studio

    SAS Studio can also be used with standard versions of SAS, perhaps as an alternative to SAS Enterprise Guide. SAS Studio includes built-in tasks for importing data from external files (Excel, for ...

    sql processing with sas system(SAS中sql应用)

    ### SQL处理在SAS系统中的应用 #### 一、引言与基础知识介绍 SAS(Statistical Analysis System)是一款广泛应用于数据分析领域的强大软件工具。它不仅支持传统的统计分析功能,还包括了数据管理、报告生成、图形...

    SAS_Programming_III英文

    1.3 SAS Processing..............................................................................................................1-19 1.4 Controlling Memory and I/O Resources..............................

    sas sql 语言 使用说明

    SAS(Statistical Analysis System,统计分析系统)是一个集数据管理、统计分析、报告输出等多种功能于一身的软件系统。SAS系统提供了丰富的过程(PROC)来处理各种统计分析问题,而其中的Proc SQL过程允许用户使用...

    SAS里面得数据挖掘功能

    ### SAS中的数据挖掘功能:深度解析与应用案例 在当今数据驱动的世界中,数据挖掘作为一项关键技能,正被广泛应用于各个领域,包括商业、科研、政府等,以揭示隐藏在大量数据背后的有价值信息。SAS(Statistical ...

    sas数据挖掘实例翻译稿

    - **Assess 类** (评估): 用于模型效果评估,如 `Assessment` 节点提供多种评估指标。 - **Scoring 类** (评分): 用于生成模型得分,如 `Score` 节点用于对新数据进行评分。 - **Utility 类** (实用工具): 包括各种...

    sas学习资料 想学习sas的朋友的不二选择~~

    - **数据挖掘与SEMMA**:本书强调了数据挖掘的重要性和SEMMA(Sample、Explore、Modify、Model、Assess)方法论,这是一种在SAS Enterprise Miner中执行数据挖掘的标准流程。 ##### 2. 通过SAS库访问SAS数据 - 书中...

    SAS.Certification.Prep.Guide.Advanced.Programming.

    New and experienced SAS users who want to prepare for the Base Programming... This guide and the accompanying CD-ROM provide you with a solid study resource as well as a go-to reference for your library.

Global site tag (gtag.js) - Google Analytics