• R代做编程辅导:CSC120 Euclidean Minimum Weight Matching


    全文链接:tecdat.cn/?p=29686 Introduction Toronto的R语言作业,和Toronto的其他作业一样,属于难度不高,但是细心度要求非常高,稍有不慎就会丢分。另外规矩也是一大堆,comment/docs/coding style什么的仅仅是最基本的要求而已。 一共写6个函数,运行后需要画10张图,然后找其中最优的欧氏距离。 调试方面,R语言还是比较方便的,打印变量、画图等,不过相对的,由于没有方便的IDE支持,编程速度相比C/C++,Java,Python倒是慢了不少。 Requirement You should use an R script for grouping up all dots in a vector including an even number of dots in this assignment, in a way that tries to minimize the sum of the distances between the dots in each of the pairs. This problem can arise in many contexts, including design of experiments in statistics. Doing this will provide practice in basic R scriptming facilities such as vectors and matrices, and use of if and for, in use of R’s plotting facilities, and in how to divide a script into several functions that can be understood and sometimes used separately. The output of the script is a vector of pairs of input dots, with each of the input dots being in exactly one pair. The order of the pairs and the order of dots in each pair are not important. The objective is to try to find a vector of pairs for which the total of the distances from one dot in a pair to the other is small. Ideally, this total distance would be as small as possible, but the method used in this assignment is not guaranteed to find a vector of groupings that achieve this minimum, it just tries to make the total distance as small as it can. The input for this problem is a vector of n dots in k-dimensional Euclidean space. The number of dots, n, will always be even. For the actual data you will work with, k is two, so the input is a vector of dots in the plane, but except for the 2-dimensional plotting function described below, your script should work for any dimensionality, k, and for any even number of dots, n. We also must specify how a function to find the groupings will work. For this assignment, you should write a function called find_groupings that can be called with a single argument that is a matrix of dots, as specified above, and which will return as its value a matrix giving the pairs of dots that we hope have a small total distance. (Below, some additional optional arguments to find_groupings will be specified.) In designing this script, we must decide how to represent the input (a vector of dots) as an R data structure. For this assignment, we will use an n by k matrix, in which each row represents a dot in k-dimensional Euclidean space. We must also decide how to represent the vector of pairs of dots that is the output. We will use an n=2 by 2 matrix for this, in which each row contains two integers between 1 and n, which index the rows for the two dots in the input matrix. For this assignment, you should test your script on a vector of 60 dots in 2-dimensional Euclidean space that you can read as a matrix as follows (storing it in a variable called data): Summary 对这门课的TA还是槽点满满,竟然最终没有拿到满分。多大的Prof和TA出的题,堪比世界第一恶心。 虽然严格要求编程习惯是好事,但是过于严格就有点过了。大部分编程习惯完全可以靠一个优秀的IDE自动调整来完成。而且时间浪费在调整格式、代码规范上面,真的值得吗?
     
  • 相关阅读:
    Android中ExpandableListView控件基本使用
    GitHub具体教程
    Could not load file or assembly'System.Data.SQLite.dll' or one of its depedencies
    Codeforces Round #253 (Div. 1) B. Andrey and Problem
    c语言中的位移位操作
    深入浅出JMS(一)——JMS简单介绍
    Java回顾之集合
    Java回顾之网络通信
    Java回顾之I/O
    Java回顾之多线程同步
  • 原文地址:https://www.cnblogs.com/tecdat/p/16841417.html
Copyright © 2020-2023  润新知