Home > Mathematica, Mathematics > On the Clock

## On the Clock

I have continued to learn a lot from Mathematica Stackexchange, Some of this has occurred with embarrassment (as I miss some obvious point). These small humiliations are, however, opportunities to learn and for improvement.

This post arises from my failure to account for the obvious challenges of modular arithmetic in relation to handling date and time data.  User Mr. Wizard is an unending source of education (done in clear, polite and with integrity).

Here (for my own educational purposes  and archive) is a way to partition a list based on elements within d of starting element:

``` sp[u_, d_] := Module[ {s, off}, s = Sort@u; off = Mod[First@s, d]; GatherBy[list, Floor[# - off, d] &] ] ```
Using a test case

`list = RandomInteger[10, 1000];`

and visualizing:
`ListPlot[sp[list, 5], PlotStyle -> {Red, Green, Blue}, Frame -> True]`

``` yields: __ATA.cmd.push(function() { __ATA.initVideoSlot('atatags-370373-5b2de446d69c0', { sectionId: '370373', format: 'inread' }); }); Advertisements __ATA.cmd.push(function() { __ATA.initSlot('atatags-26942-5b2de446d6a05', { collapseEmpty: 'before', sectionId: '26942', width: 300, height: 250 }); }); __ATA.cmd.push(function() { __ATA.initSlot('atatags-114160-5b2de446d6a09', { collapseEmpty: 'before', sectionId: '114160', width: 300, height: 250 }); }); Like this:Like Loading... Related ```
``` Categories: Mathematica, Mathematics ```
``` Comments (0) Trackbacks (0) Leave a comment Trackback No comments yet. No trackbacks yet. Leave a Reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. ( Log Out /  Change ) You are commenting using your Google+ account. ( Log Out /  Change ) You are commenting using your Twitter account. ( Log Out /  Change ) You are commenting using your Facebook account. ( Log Out /  Change ) w Cancel Connecting to %s var highlander_expando_javascript = function(){ var input = document.createElement( 'input' ), comment = jQuery( '#comment' ); if ( 'placeholder' in input ) { comment.attr( 'placeholder', jQuery( '.comment-textarea label' ).remove().text() ); } // Expando Mode: start small, then auto-resize on first click + text length jQuery( '#comment-form-identity' ).hide(); jQuery( '#comment-form-subscribe' ).hide(); jQuery( '#commentform .form-submit' ).hide(); comment.css( { 'height':'10px' } ).one( 'focus', function() { var timer = setInterval( HighlanderComments.resizeCallback, 10 ) jQuery( this ).animate( { 'height': HighlanderComments.initialHeight } ).delay( 100 ).queue( function(n) { clearInterval( timer ); HighlanderComments.resizeCallback(); n(); } ); jQuery( '#comment-form-identity' ).slideDown(); jQuery( '#comment-form-subscribe' ).slideDown(); jQuery( '#commentform .form-submit' ).slideDown(); }); } jQuery(document).ready( highlander_expando_javascript ); Notify me of new comments via email. Happy Numbers The Seven Daughters of Eve ```
``` RSS feed Google Youdao Xian Guo Zhua Xia My Yahoo! newsgator Bloglines iNezha Recent Posts Fun with Fractions A Bookmark Fun Animation Stretching and Folding Harmony on a Donut CategoriesCategories Select Category books  (93) LaTeX  (2) Mathematica  (149) Mathematics  (158) philosophical rants  (3) R statistical computing software  (4) Uncategorized  (68) /* <![CDATA[ */ (function() { var dropdown = document.getElementById( "cat" ); function onCatChange() { if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) { dropdown.parentNode.submit(); } } dropdown.onchange = onCatChange; })(); /* ]]> */ Search this blog Search for: Tweets RT @Heart_BMJ: Novel United Kingdom prognostic model for 30-day mortality following transcatheter aortic valve implantation | Heart https:/… 1 hour ago RT @MusaSharkawi: Older pt w/ gastric cancer p/w stroke. This is the classic appearance for marantic endocarditis AKA non-bacterial thrombo… 1 hour ago RT @NEJM: Clinical Practice: Management of Endogenous Subclinical Hyperthyroidism nej.md/2lmtsRZ https://t.co/B0Jty8xsPq 1 hour ago RT @ESC_Journals: MUST READ: Standardized End Point Definitions for Coronary Intervention Trials: The Academic Research Consortium-2 Consen… 1 hour ago RT @theheartorg: Results of SORT OUT VIII from #EuroPCR: ms.spr.ly/6017rNFS3 1 hour ago Follow @ubpdqnBlogsUnknown Blogger Unknown Blogger Blogspot Pinterest Rebelmouse weebly Mathematica SitesLunchtime Playground: Fun with Mathematica Mathematica Bits Wolfram Blog Mathematica Users About Blog Stats 23,218 hits Blogsbit-player Hyndsight Advertisements __ATA.cmd.push(function() { __ATA.initSlot('atatags-286348-5b2de446dbeb3', { collapseEmpty: 'before', sectionId: '286348', width: 300, height: 250 }); }); ```
``` Top Create a free website or blog at WordPress.com. ```
``` ```
``` /* <![CDATA[ */ var WPGroHo = {"my_hash":""}; /* ]]> */ //initialize and attach hovercards to all gravatars jQuery( document ).ready( function( \$ ) { if (typeof Gravatar === "undefined"){ return; } if ( typeof Gravatar.init !== "function" ) { return; } Gravatar.profile_cb = function( hash, id ) { WPGroHo.syncProfileData( hash, id ); }; Gravatar.my_hash = WPGroHo.my_hash; Gravatar.init( 'body', '#wp-admin-bar-my-account' ); }); /* <![CDATA[ */ var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1\$s: You are commenting using your %2\$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"https:\/\/ubpdqnmathematica.wordpress.com\/public.api\/connect\/?action=request","logoutURL":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-login.php?action=logout&_wpnonce=f2ec8a9c7d","homeURL":"https:\/\/ubpdqnmathematica.wordpress.com\/","postID":"2048","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"0","userIsLoggedIn":"","isJetpack":"","text_direction":"ltr"}; /* ]]> */ Post to Cancel Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy /* <![CDATA[ */ var actionbardata = {"siteID":"20600477","siteName":"Unknown Blogger Mathematica","siteURL":"http:\/\/ubpdqnmathematica.wordpress.com","icon":"<img alt='' src='https:\/\/s2.wp.com\/i\/logo\/wpcom-gray-white.png' class='avatar avatar-50' height='50' width='50' \/>","canManageOptions":"","canCustomizeSite":"","isFollowing":"","themeSlug":"pub\/inove","signupURL":"https:\/\/wordpress.com\/start\/","loginURL":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-login.php?redirect_to=https%3A%2F%2Fubpdqnmathematica.wordpress.com%2F2013%2F09%2F29%2Fon-the-clock%2F","themeURL":"","xhrURL":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-admin\/admin-ajax.php","nonce":"1406bdb907","isSingular":"1","isFolded":"","isLoggedIn":"","isMobile":"","subscribeNonce":"<input type=\"hidden\" id=\"_wpnonce\" name=\"_wpnonce\" value=\"2c3be23f46\" \/>","referer":"https:\/\/ubpdqnmathematica.wordpress.com\/2013\/09\/29\/on-the-clock\/","canFollow":"1","feedID":"1282330","statusMessage":"","customizeLink":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-admin\/customize.php?url=https%3A%2F%2Fubpdqnmathematica.wordpress.com%2F2013%2F09%2F29%2Fon-the-clock%2F","postID":"2048","shortlink":"https:\/\/wp.me\/p1or7L-x2","canEditPost":"","editLink":"https:\/\/wordpress.com\/post\/ubpdqnmathematica.wordpress.com\/2048","statsLink":"https:\/\/wordpress.com\/stats\/post\/2048\/ubpdqnmathematica.wordpress.com","i18n":{"view":"View site","follow":"Follow","following":"Following","edit":"Edit","login":"Log in","signup":"Sign up","customize":"Customize","report":"Report this content","themeInfo":"Get theme: INove","shortlink":"Copy shortlink","copied":"Copied","followedText":"New posts from this site will now appear in your <a href=\"https:\/\/wordpress.com\/\">Reader<\/a>","foldBar":"Collapse this bar","unfoldBar":"Expand this bar","editSubs":"Manage subscriptions","viewReader":"View site in Reader","viewReadPost":"View post in Reader","subscribe":"Sign me up","enterEmail":"Enter your email address","followers":"Join 70 other followers","alreadyUser":"Already have a WordPress.com account? <a href=\"https:\/\/ubpdqnmathematica.wordpress.com\/wp-login.php?redirect_to=https%3A%2F%2Fubpdqnmathematica.wordpress.com%2F2013%2F09%2F29%2Fon-the-clock%2F\">Log in now.<\/a>","stats":"Stats"}}; /* ]]> */ /* <![CDATA[ */ var jetpackCarouselStrings = {"widths":[370,700,1000,1200,1400,2000],"is_logged_in":"","lang":"en","ajaxurl":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-admin\/admin-ajax.php","nonce":"c4a73e6ef0","display_exif":"1","display_geo":"1","single_image_gallery":"1","single_image_gallery_media_file":"","background_color":"black","comment":"Comment","post_comment":"Post Comment","write_comment":"Write a Comment...","loading_comments":"Loading Comments...","download_original":"View full size <span class=\"photo-size\">{0}<span class=\"photo-size-times\">\u00d7<\/span>{1}<\/span>","no_comment_text":"Please be sure to submit some text with your comment.","no_comment_email":"Please provide an email address to comment.","no_comment_author":"Please provide your name to comment.","comment_post_error":"Sorry, but there was an error posting your comment. Please try again later.","comment_approved":"Your comment was approved.","comment_unapproved":"Your comment is in moderation.","camera":"Camera","aperture":"Aperture","shutter_speed":"Shutter Speed","focal_length":"Focal Length","copyright":"Copyright","comment_registration":"0","require_name_email":"1","login_url":"https:\/\/ubpdqnmathematica.wordpress.com\/wp-login.php?redirect_to=https%3A%2F%2Fubpdqnmathematica.wordpress.com%2F2013%2F09%2F29%2Fon-the-clock%2F","blog_id":"20600477","meta_data":["camera","aperture","shutter_speed","focal_length","copyright"],"local_comments_commenting_as":"<fieldset><label for=\"email\">Email (Required)<\/label> <input type=\"text\" name=\"email\" class=\"jp-carousel-comment-form-field jp-carousel-comment-form-text-field\" id=\"jp-carousel-comment-form-email-field\" \/><\/fieldset><fieldset><label for=\"author\">Name (Required)<\/label> <input type=\"text\" name=\"author\" class=\"jp-carousel-comment-form-field jp-carousel-comment-form-text-field\" id=\"jp-carousel-comment-form-author-field\" \/><\/fieldset><fieldset><label for=\"url\">Website<\/label> <input type=\"text\" name=\"url\" class=\"jp-carousel-comment-form-field jp-carousel-comment-form-text-field\" id=\"jp-carousel-comment-form-url-field\" \/><\/fieldset>","reblog":"Reblog","reblogged":"Reblogged","reblog_add_thoughts":"Add your thoughts here... (optional)","reblogging":"Reblogging...","post_reblog":"Post Reblog","stats_query_args":"blog=20600477&v=wpcom&tz=10&user_id=0&subd=ubpdqnmathematica","is_public":"1","reblog_enabled":""}; /* ]]> */ // <![CDATA[ (function() { try{ if ( window.external &&'msIsSiteMode' in window.external) { if (window.external.msIsSiteMode()) { var jl = document.createElement('script'); jl.type='text/javascript'; jl.async=true; jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jl, s); } } }catch(e){} })(); // ]]> var skimlinks_pub_id = "725X584219" var skimlinks_sitename = "ubpdqnmathematica.wordpress.com"; %d bloggers like this: _tkq = window._tkq || []; _stq = window._stq || []; _tkq.push(['storeContext', {'blog_id':'20600477','blog_tz':'10','user_lang':'en','blog_lang':'en','user_id':'0'}]); _stq.push(['view', {'blog':'20600477','v':'wpcom','tz':'10','user_id':'0','post':'2048','subd':'ubpdqnmathematica'}]); _stq.push(['extra', {'crypt':'UE5XaGUuOTlwaD85flAmcm1mcmZsaDhkV11YdT1UeVRla1NLdXYlUnJLd195UG5zUFp5T2RzdmE/LTAxdXxOL352LnxpX2ZhU1BYWlpXajJ5anVPSFB1eDc0dkUtdz9kUWg2TjhHQ24/S0ZxLSVLJVpvNXxLNXdoMDI3eSZYSngtcGJ0blsrWT8uQmhXbVVNTltNcXhrTkw5WGNEbV9LTS9TV209flZ2XXRoLllMK0YrNS0sRXl3V1ZsbXYsR1NaYkJbVm1xcnE2UTdCX2w1dHw4UCtVMUp8U3VYK0pKc2RLaldSelpJW24vdGViMy80fk9Dak9FNGduTE9mcF9CMklYMjB5ZHFRZllPUDROTFk0Nk8wW2xJPVVLPz8rXy9jLHQuQkNHdA=='}]); _stq.push([ 'clickTrackerInit', '20600477', '2048' ]); if ( 'object' === typeof wpcom_mobile_user_agent_info ) { wpcom_mobile_user_agent_info.init(); var mobileStatsQueryString = ""; if( false !== wpcom_mobile_user_agent_info.matchedPlatformName ) mobileStatsQueryString += "&x_" + 'mobile_platforms' + '=' + wpcom_mobile_user_agent_info.matchedPlatformName; if( false !== wpcom_mobile_user_agent_info.matchedUserAgentName ) mobileStatsQueryString += "&x_" + 'mobile_devices' + '=' + wpcom_mobile_user_agent_info.matchedUserAgentName; if( wpcom_mobile_user_agent_info.isIPad() ) mobileStatsQueryString += "&x_" + 'ipad_views' + '=' + 'views'; if( "" != mobileStatsQueryString ) { new Image().src = document.location.protocol + '//pixel.wp.com/g.gif?v=wpcom-no-pv' + mobileStatsQueryString + '&baba=' + Math.random(); } } ```