miaaltieri / mean_median_stream Goto Github PK
View Code? Open in Web Editor NEWThis program streams a JSON file and prints a summary of the data it has seen "so far" every 1000 records
This program streams a JSON file and prints a summary of the data it has seen "so far" every 1000 records
Build: javac DataSummary.java Execute: java DataSummary File Location: in order for this to run it will need a JSON file named user-1.json, and this file must be located at '~/user-1.json' NOTE: Completion of the project is currently at deadlock, due to being unable to add GSON to my classpath or use GSON in eclipse. HOW I CALCULATED MEDIAN: Calculating a median over a large data set can be computationally expensive and expensive in the sense of storage. I looked at various libraries for calculating a running median as well as other techniques, but nothing was quite what I needed, so I fashioned my own solution: it is suggested that you follow along with the function: void computeMedian(Hashtable values, int size) in DataSummary.java As I looked at each value I store every number encountered in a Hashtable, the number as the key and the value is the number of time that number was encounterd. i.e. stream 4,9,1,2,9,9,3,3,1,9,9,9 would have the hashtable: [ 1:2, 2:1 , 3:2 , 4:1 , 9:6] then when calculating a mean I would see what the length of was the stream, in this program that is the variable `count`, and in the example above it is 12. I would then divide that length into 2 and try to find the value at that point, the length/2 is also know as `remaining` To find the value at that point I would grab the lowest key in the hashtable, and see how many values corresponded with that key, and subtract that number from `remaining`. NOW if after a subtraction remaining < 0: return that key, because that means that length/2 occured when that key was present OR if remaining = 0: return (this key + next smallest key) / 2, because it means that the middle occurs between this value and the next smallest value. example: stream 4,9,1,2,9,9,3,3,1,9,9,9 produces hashtable: [ 1:2, 2:1 , 3:2 , 4:1 , 9:6] count = 12 remaining = 6 smallest key = 1 corresponding value = 2 update remaining = 4 next smallest key = 2 corresponding value = 1 update remaining = 3 next smallest key = 3 corresponding value = 2 update remaining = 1 next smallest key = 4 corresponding value = 1 update remaining = 0 NOTE this means the median is inbetween this value and the next value so return (4 + 9)/2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.