simplification

How to efficiently get 10% of random numbers, then 10% of remaining 90 etc untill all points allocated

落花浮王杯 提交于 2019-12-11 00:16:58
问题 This is what I want to do : I have 300 000 points. I want 10% of the points. I then want 10% of the remaining 90% of points. I then want 10% of the remaining 81% of points I then want 10% of the remaining 73% of points etc until i'm finished with all the points. Is this the fastest way of doing it: #all the points s = np.arange(len(c_list)) np.random.shuffle(s) #first 10% s1 = np.arange(len(c_list)*10/100) np.random.shuffle(s1) k = s1 while len(k)<len(s) : r = [x for x in s if x not in k]#get

simplifying regular expression

家住魔仙堡 提交于 2019-12-10 13:45:52
问题 I am going through exercises regarding regular expressions, and I am really unsure on how to do this. The regular expression is: ((a*)(b*))* ∪ (a*) I am really bad at this, but I think that ((a*)(b*))* can be simplified to (a ∪ b)* But if this is right, than the last ∪ (a*) is really just a repetition, so I figure the whole expression can be simplified to (a ∪ b)*. Does this seem correct? Edit: ∪ stands for union 回答1: You are right. (a*b*)* can match any string of a's and b's, so can (a U b)*

Python : Ramer-Douglas-Peucker (RDP) algorithm with number of points instead of epsilon

可紊 提交于 2019-12-09 16:47:14
问题 I would like to modify this following python script for RDP algorithm with the purpose of not using epsilon but to choose the number of points I want to keep at the final : class DPAlgorithm(): def distance(self, a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def point_line_distance(self, point, start, end): if (start == end): return self.distance(point, start) else: n = abs( (end[0] - start[0]) * (start[1] - point[1]) - (start[0] - point[0]) * (end[1] - start[1]) ) d = sqrt(

line simplification algorithm: Visvalingam vs Douglas-Peucker

微笑、不失礼 提交于 2019-12-09 16:01:23
问题 I am trying to implement a line simplification algorithm . The main 2 algorithms I found are: Ramer-Douglas-Peucker Visvalingam-Whyat Currently I am running a few simulations of them on Matlab in order to determine which answers my needs better. The main goal for the algorithm is to simlipfy polygons in a map. My Input is a polygon\polyline and a threshold for mistake- epsilon. I need the simplified polygon to be as close as possible to the original, and I do not have a requirment for number

How to fix my simplification function for power rule (to make results easier to read) for a working Symbolic differentiation function in Racket?

与世无争的帅哥 提交于 2019-12-08 06:01:36
问题 This is my function for differentiation that works correctly. #lang racket (define (diff x expr) (if (not (list? expr)) (if (equal? x expr) 1 0) (let ( (operation (car expr)) (u (cadr expr)) (v (caddr expr))) (case operation ((+) (list '+ (diff x u) (diff x v))) ((-) (list '- (diff x u) (diff x v))) ((*) (list '+ (list '* u (diff x v)) (list '* v (diff x u)))) ((/) (list '/ (list '- (list '* v (diff x u)) (list '* u (diff x v))) (list '* v v))) ((^) (list '* v (list '* (list '^ u (- v 1))

Python : Ramer-Douglas-Peucker (RDP) algorithm with number of points instead of epsilon

若如初见. 提交于 2019-12-04 04:42:50
I would like to modify this following python script for RDP algorithm with the purpose of not using epsilon but to choose the number of points I want to keep at the final : class DPAlgorithm(): def distance(self, a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def point_line_distance(self, point, start, end): if (start == end): return self.distance(point, start) else: n = abs( (end[0] - start[0]) * (start[1] - point[1]) - (start[0] - point[0]) * (end[1] - start[1]) ) d = sqrt( (end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2 ) return n / d def rdp(self, points, epsilon): """

How do I reduce the coordinate count of an arbitrary SVG path, without losing much or any precision?

喜欢而已 提交于 2019-12-03 12:32:25
问题 I am scouring the web for tools, programs, utilities, supporting libraries and code primitives that help optimize SVGs for simplicity, space and elegance recently, to link to from the Kilobyte SVG Challenge's tools section, but have yet to find good primitives focusing on how to reduce the number of coordinates of a path, without losing much – or ideally any – precision. Take this marker-augmented version of the Coca Cola logo, for instance (~7kb, essentially all path data) – which very

Why does iPhone sample code use so many intermediate variables?

混江龙づ霸主 提交于 2019-12-02 01:03:18
问题 I'm currently working through Apress's "Beginning iPhone 3 Development". A standard they use in their example applications is like the following code: - (void)viewDidLoad { BlueViewController *blueController = [[BlueViewController alloc] initWithNibName:@"BlueView" bundle:nil]; self.blueViewController = blueController; [self.view insertSubview:blueController.view atIndex:0]; [blueController release]; } 8.14.11 UPDATE (additional information) blueViewController is declared as follows:

Simplification Algorithm for Reverse Polish Notation

≡放荡痞女 提交于 2019-12-01 12:27:19
A couple of days ago I played around with Befunge which is an esoteric programming language. Befunge uses a LIFO stack to store data. When you write programs the digits from 0 to 9 are actually Befunge-instructions which push the corresponding values onto the stack. So for exmaple this would push a 7 to stack: 34+ In order to push a number greater than 9, calculations must be done with numbers less than or equal to 9. This would yield 123. 99*76*+ While solving Euler Problem 1 with Befunge I had to push the fairly large number 999 to the stack. Here I began to wonder how I could accomplish

Simplification Algorithm for Reverse Polish Notation

荒凉一梦 提交于 2019-12-01 11:46:31
问题 A couple of days ago I played around with Befunge which is an esoteric programming language. Befunge uses a LIFO stack to store data. When you write programs the digits from 0 to 9 are actually Befunge-instructions which push the corresponding values onto the stack. So for exmaple this would push a 7 to stack: 34+ In order to push a number greater than 9, calculations must be done with numbers less than or equal to 9. This would yield 123. 99*76*+ While solving Euler Problem 1 with Befunge I