The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
| def simpson(a, b, f, N): | |
| return (1.0 / 3.0) * (2 * (((b - a) / N) * \ | |
| sum(f(v) for v in [i * ((b - a) / (2. * N))\ | |
| for i in range(2 * N + 1)][1:2 * N + 1:2]))\ | |
| + (((b - a) / N) * ((f(a) + f(b)) / 2.0 + sum\ | |
| (f(v * ((b - a) / N) + a) for v in xrange(1, N | |
| ))))) | |
| # int_0^1 x^2 + 2 + 2 = 1/3 | |
| print simpson(0,1,lambda x:x**2+x*2+2, 100) |
| import java.util.Random; | |
| /** | |
| * Implements the Epsilon Greedy Bandit algorithm for finding | |
| * optimal probabilities of success given k binomial distributions. | |
| */ | |
| public class EpsilonGreedyBandit { | |
| private final double [] SAMPLE_ARMS; | |
| private final float GREEDYNESS; | |
| private int[] numberOfSuccesses; |
| // http://app.toronto.ca/DevelopmentApplications/dwr/test/MapSearchService | |
| var reply0 = function(data) | |
| { | |
| if (data != null && typeof data == 'object') console.log(dwr.util.toDescriptiveString(data, 100)); | |
| else dwr.util.setValue('d0', dwr.util.toDescriptiveString(data, 1)); | |
| } | |
| function keep_alive() { | |
| http_request = new XMLHttpRequest(); |
| [ | |
| { | |
| communityInfo:null, | |
| folderDescription:"Proposed Canada Post Depot building with a gross floor area of 1858.45 sq. m. (20,005 sq.ft.). The facility will provide for final mail sorting and destination delivery, with ancillary offices, employee locker rooms, etc.. A total of 205 parking parking spaces are proposed to supply both employee parking and fleet parking for the postal delivery vans (5-ton vehicles only). This is a new Canada Post prototype facility where the delivery van drivers will also now have traditional mail routes to provide actual door-to-door mail delivery as well. Building coverage proposed is approximately 18.5%, with approximately 9.4% of the site to be landscaped. The building is proposed to be LEED certified and energy efficient. NOAC issued Aug. 6, 2013, signed by Greg Lintern, Director, Community Planning.", | |
| folderRevision:"37", | |
| folderRsn:3250063, | |
| folderSection:"ESC", | |
| folderSequence:"278253", | |
| folderType:"SA", | |
| folderTypeDesc:"Site Plan |
| """ | |
| Author: Jason Liu | |
| """ | |
| from __future__ import division | |
| from collections import defaultdict | |
| from nltk.corpus import stopwords | |
| from string import maketrans, punctuation | |
| from itertools import imap |
| """ | |
| This is a effective random uniform sampling module known as | |
| Reservoir Sampling which uniformly samples a subset of k elements from a larger | |
| 'reservoir' of size N where N is usually unknown or very large. | |
| This command line tool and be piped a stream or inputed a file. | |
| Author: Jason Liu | |
| Date: May 24th, 2014 |
| ### MATPLOTLIBRC FORMAT | |
| # This is a sample matplotlib configuration file - you can find a copy | |
| # of it on your system in | |
| # site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
| # there, please note that it will be overridden in your next install. | |
| # If you want to keep a permanent local copy that will not be | |
| # over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
| # like systems) and C:\Documents and Settings\yourname\.matplotlib | |
| # (win32 systems). |
| def qsort(xs): | |
| if xs == []: | |
| return xs | |
| else: | |
| fst, *rst = xs | |
| sm = qsort(list((x for x in rst if x <= fst))) | |
| lg = qsort(list((x for x in rst if x > fst))) | |
| return sm + [fst] + lg |