{"action":"created","comment":{"url":"https://api.github.com/repos/mathics/Mathics/pulls/comments/34133210","id":34133210,"diff_hunk":"@@ -2120,4 +2120,99 @@ class Total(Builtin):\n     rules = {\n         'Total[head_]': 'Apply[Plus, head]',\n         'Total[head_, n_]': 'Apply[Plus, Flatten[head, n]]'\n-    }\n\\ No newline at end of file\n+    }\n+\n+\n+class Mean(Builtin):\n+    \"\"\"\n+    <dl>\n+    <dt>'Mean[$list$]'\n+    <dd>\n+        Mean over all values in list (Total[list] / Length[list])\n+    </dd>\n+    </dt>\n+    </dl>\n+    >> Mean[{1,2,3}]\n+     = 2\n+    >> Mean[{a, b, 213}]\n+     = (123 + a + b) / 3\n+    \"\"\"\n+    rules = {\n+        'Mean[list_List]': 'Total[list] / Length[list]'\n+    }\n+\n+\n+class Variance(Builtin):\n+    \"\"\"\n+    <dl>\n+    <dt>'Mean[$list$]'\n+    <dd>\n+        Mean over all values in list (Total[list] / Length[list])\n+    </dd>\n+    </dt>\n+    </dl>\n+    >> Mean[{1,2,3}]\n+     = 2\n+    >> Mean[{a, b, 213}]\n+     = (123 + a + b) / 3\n+    \"\"\"\n+\n+    rules = {\n+        'Variance[list_List]': '(list-Mean[list]).Conjugate[list-Mean[list]]/(Length[list]-1)'\n+    }\n+\n+\n+class StandardDeviation(Builtin):\n+    rules = {\n+        'StandardDeviation[list_List]': 'Sqrt[Variance[list]]'\n+    }\n+\n+class Quantile(Builtin):\n+\n+    rules = {\n+        'Quantile[list_List, q_RealValueQ]': 'Sort[list, Less][[Ceiling[q * Length[list]]]]',\n+        'Quantile[list_List, q_List]': 'Quantile[list, singleq] /@ q'\n+    }\n+\n+\n+class Diagonal(Builtin):\n+    rules = {\n+        'Diagonal[l_List, k]': 'Module[{k = 0, j = 0, i = 0}, If[n > 0, j = n, k = -n]; Table[l[[i + k, i + j]], {i, 1, Min[Dimensions[l] - {k, j}]}]]',\n+        'Diagonal[l_List]' : 'Module[{i = 0}, Table[l[[i, i]], {i, 1, Min[Dimensions[l]]}]]'\n+    }\n+\n+\n+class Tr(Builtin):","path":"mathics/builtin/lists.py","position":68,"original_position":68,"commit_id":"bca5de1d2bd4ce80f537d6cf24df098194254d33","original_commit_id":"bca5de1d2bd4ce80f537d6cf24df098194254d33","user":{"login":"wolfv","id":885054,"avatar_url":"https://avatars.githubusercontent.com/u/885054?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfv","html_url":"https://github.com/wolfv","followers_url":"https://api.github.com/users/wolfv/followers","following_url":"https://api.github.com/users/wolfv/following{/other_user}","gists_url":"https://api.github.com/users/wolfv/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfv/subscriptions","organizations_url":"https://api.github.com/users/wolfv/orgs","repos_url":"https://api.github.com/users/wolfv/repos","events_url":"https://api.github.com/users/wolfv/events{/privacy}","received_events_url":"https://api.github.com/users/wolfv/received_events","type":"User","site_admin":false},"body":"(assuming this is the TODO for Tr / Trace).\r\n\r\nThe Trace works in general, however, the Tr[m_List, head_, level_] doesn't, because Flatten is the wrong operator. So this needs to be fixed, or left out for now...\r\n\r\nI think it needs to be something like partition, and then Fold the operator around the newly created list. ","created_at":"2015-07-08T10:11:58Z","updated_at":"2015-07-08T10:11:58Z","html_url":"https://github.com/mathics/Mathics/pull/271#discussion_r34133210","pull_request_url":"https://api.github.com/repos/mathics/Mathics/pulls/271","_links":{"self":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/comments/34133210"},"html":{"href":"https://github.com/mathics/Mathics/pull/271#discussion_r34133210"},"pull_request":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/271"}}},"pull_request":{"url":"https://api.github.com/repos/mathics/Mathics/pulls/271","id":39378694,"html_url":"https://github.com/mathics/Mathics/pull/271","diff_url":"https://github.com/mathics/Mathics/pull/271.diff","patch_url":"https://github.com/mathics/Mathics/pull/271.patch","issue_url":"https://api.github.com/repos/mathics/Mathics/issues/271","number":271,"state":"open","locked":false,"title":"WIP: Wolfv more linalg","user":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"body":"Finishing off some of @wolfv's misc. improvements","created_at":"2015-07-07T14:51:45Z","updated_at":"2015-07-08T10:11:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7b850cf5ccf7c0c8ec75c2e3e28bdf57bc87d92","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mathics/Mathics/pulls/271/commits","review_comments_url":"https://api.github.com/repos/mathics/Mathics/pulls/271/comments","review_comment_url":"https://api.github.com/repos/mathics/Mathics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mathics/Mathics/issues/271/comments","statuses_url":"https://api.github.com/repos/mathics/Mathics/statuses/bca5de1d2bd4ce80f537d6cf24df098194254d33","head":{"label":"sn6uv:wolfv-more-linalg","ref":"wolfv-more-linalg","sha":"bca5de1d2bd4ce80f537d6cf24df098194254d33","user":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"repo":{"id":4579327,"name":"Mathics","full_name":"sn6uv/Mathics","owner":{"login":"sn6uv","id":1217643,"avatar_url":"https://avatars.githubusercontent.com/u/1217643?v=3","gravatar_id":"","url":"https://api.github.com/users/sn6uv","html_url":"https://github.com/sn6uv","followers_url":"https://api.github.com/users/sn6uv/followers","following_url":"https://api.github.com/users/sn6uv/following{/other_user}","gists_url":"https://api.github.com/users/sn6uv/gists{/gist_id}","starred_url":"https://api.github.com/users/sn6uv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn6uv/subscriptions","organizations_url":"https://api.github.com/users/sn6uv/orgs","repos_url":"https://api.github.com/users/sn6uv/repos","events_url":"https://api.github.com/users/sn6uv/events{/privacy}","received_events_url":"https://api.github.com/users/sn6uv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sn6uv/Mathics","description":"a general-purpose computer algebra system","fork":true,"url":"https://api.github.com/repos/sn6uv/Mathics","forks_url":"https://api.github.com/repos/sn6uv/Mathics/forks","keys_url":"https://api.github.com/repos/sn6uv/Mathics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sn6uv/Mathics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sn6uv/Mathics/teams","hooks_url":"https://api.github.com/repos/sn6uv/Mathics/hooks","issue_events_url":"https://api.github.com/repos/sn6uv/Mathics/issues/events{/number}","events_url":"https://api.github.com/repos/sn6uv/Mathics/events","assignees_url":"https://api.github.com/repos/sn6uv/Mathics/assignees{/user}","branches_url":"https://api.github.com/repos/sn6uv/Mathics/branches{/branch}","tags_url":"https://api.github.com/repos/sn6uv/Mathics/tags","blobs_url":"https://api.github.com/repos/sn6uv/Mathics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sn6uv/Mathics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sn6uv/Mathics/git/refs{/sha}","trees_url":"https://api.github.com/repos/sn6uv/Mathics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sn6uv/Mathics/statuses/{sha}","languages_url":"https://api.github.com/repos/sn6uv/Mathics/languages","stargazers_url":"https://api.github.com/repos/sn6uv/Mathics/stargazers","contributors_url":"https://api.github.com/repos/sn6uv/Mathics/contributors","subscribers_url":"https://api.github.com/repos/sn6uv/Mathics/subscribers","subscription_url":"https://api.github.com/repos/sn6uv/Mathics/subscription","commits_url":"https://api.github.com/repos/sn6uv/Mathics/commits{/sha}","git_commits_url":"https://api.github.com/repos/sn6uv/Mathics/git/commits{/sha}","comments_url":"https://api.github.com/repos/sn6uv/Mathics/comments{/number}","issue_comment_url":"https://api.github.com/repos/sn6uv/Mathics/issues/comments{/number}","contents_url":"https://api.github.com/repos/sn6uv/Mathics/contents/{+path}","compare_url":"https://api.github.com/repos/sn6uv/Mathics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sn6uv/Mathics/merges","archive_url":"https://api.github.com/repos/sn6uv/Mathics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sn6uv/Mathics/downloads","issues_url":"https://api.github.com/repos/sn6uv/Mathics/issues{/number}","pulls_url":"https://api.github.com/repos/sn6uv/Mathics/pulls{/number}","milestones_url":"https://api.github.com/repos/sn6uv/Mathics/milestones{/number}","notifications_url":"https://api.github.com/repos/sn6uv/Mathics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sn6uv/Mathics/labels{/name}","releases_url":"https://api.github.com/repos/sn6uv/Mathics/releases{/id}","created_at":"2012-06-06T23:51:57Z","updated_at":"2014-11-02T02:18:07Z","pushed_at":"2015-07-07T14:49:58Z","git_url":"git://github.com/sn6uv/Mathics.git","ssh_url":"git@github.com:sn6uv/Mathics.git","clone_url":"https://github.com/sn6uv/Mathics.git","svn_url":"https://github.com/sn6uv/Mathics","homepage":"http://www.mathics.org","size":12674,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":9,"default_branch":"master"}},"base":{"label":"mathics:master","ref":"master","sha":"b8fc75b630c15c23f6a64574114a34728439fbb7","user":{"login":"mathics","id":655749,"avatar_url":"https://avatars.githubusercontent.com/u/655749?v=3","gravatar_id":"","url":"https://api.github.com/users/mathics","html_url":"https://github.com/mathics","followers_url":"https://api.github.com/users/mathics/followers","following_url":"https://api.github.com/users/mathics/following{/other_user}","gists_url":"https://api.github.com/users/mathics/gists{/gist_id}","starred_url":"https://api.github.com/users/mathics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathics/subscriptions","organizations_url":"https://api.github.com/users/mathics/orgs","repos_url":"https://api.github.com/users/mathics/repos","events_url":"https://api.github.com/users/mathics/events{/privacy}","received_events_url":"https://api.github.com/users/mathics/received_events","type":"Organization","site_admin":false},"repo":{"id":1341741,"name":"Mathics","full_name":"mathics/Mathics","owner":{"login":"mathics","id":655749,"avatar_url":"https://avatars.githubusercontent.com/u/655749?v=3","gravatar_id":"","url":"https://api.github.com/users/mathics","html_url":"https://github.com/mathics","followers_url":"https://api.github.com/users/mathics/followers","following_url":"https://api.github.com/users/mathics/following{/other_user}","gists_url":"https://api.github.com/users/mathics/gists{/gist_id}","starred_url":"https://api.github.com/users/mathics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathics/subscriptions","organizations_url":"https://api.github.com/users/mathics/orgs","repos_url":"https://api.github.com/users/mathics/repos","events_url":"https://api.github.com/users/mathics/events{/privacy}","received_events_url":"https://api.github.com/users/mathics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mathics/Mathics","description":"a general-purpose computer algebra system","fork":false,"url":"https://api.github.com/repos/mathics/Mathics","forks_url":"https://api.github.com/repos/mathics/Mathics/forks","keys_url":"https://api.github.com/repos/mathics/Mathics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mathics/Mathics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mathics/Mathics/teams","hooks_url":"https://api.github.com/repos/mathics/Mathics/hooks","issue_events_url":"https://api.github.com/repos/mathics/Mathics/issues/events{/number}","events_url":"https://api.github.com/repos/mathics/Mathics/events","assignees_url":"https://api.github.com/repos/mathics/Mathics/assignees{/user}","branches_url":"https://api.github.com/repos/mathics/Mathics/branches{/branch}","tags_url":"https://api.github.com/repos/mathics/Mathics/tags","blobs_url":"https://api.github.com/repos/mathics/Mathics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mathics/Mathics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mathics/Mathics/git/refs{/sha}","trees_url":"https://api.github.com/repos/mathics/Mathics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mathics/Mathics/statuses/{sha}","languages_url":"https://api.github.com/repos/mathics/Mathics/languages","stargazers_url":"https://api.github.com/repos/mathics/Mathics/stargazers","contributors_url":"https://api.github.com/repos/mathics/Mathics/contributors","subscribers_url":"https://api.github.com/repos/mathics/Mathics/subscribers","subscription_url":"https://api.github.com/repos/mathics/Mathics/subscription","commits_url":"https://api.github.com/repos/mathics/Mathics/commits{/sha}","git_commits_url":"https://api.github.com/repos/mathics/Mathics/git/commits{/sha}","comments_url":"https://api.github.com/repos/mathics/Mathics/comments{/number}","issue_comment_url":"https://api.github.com/repos/mathics/Mathics/issues/comments{/number}","contents_url":"https://api.github.com/repos/mathics/Mathics/contents/{+path}","compare_url":"https://api.github.com/repos/mathics/Mathics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mathics/Mathics/merges","archive_url":"https://api.github.com/repos/mathics/Mathics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mathics/Mathics/downloads","issues_url":"https://api.github.com/repos/mathics/Mathics/issues{/number}","pulls_url":"https://api.github.com/repos/mathics/Mathics/pulls{/number}","milestones_url":"https://api.github.com/repos/mathics/Mathics/milestones{/number}","notifications_url":"https://api.github.com/repos/mathics/Mathics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mathics/Mathics/labels{/name}","releases_url":"https://api.github.com/repos/mathics/Mathics/releases{/id}","created_at":"2011-02-08T11:53:13Z","updated_at":"2015-07-03T08:43:18Z","pushed_at":"2015-07-07T14:51:45Z","git_url":"git://github.com/mathics/Mathics.git","ssh_url":"git@github.com:mathics/Mathics.git","clone_url":"https://github.com/mathics/Mathics.git","svn_url":"https://github.com/mathics/Mathics","homepage":"http://www.mathics.org","size":12773,"stargazers_count":465,"watchers_count":465,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":85,"mirror_url":null,"open_issues_count":49,"forks":85,"open_issues":49,"watchers":465,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/271"},"html":{"href":"https://github.com/mathics/Mathics/pull/271"},"issue":{"href":"https://api.github.com/repos/mathics/Mathics/issues/271"},"comments":{"href":"https://api.github.com/repos/mathics/Mathics/issues/271/comments"},"review_comments":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/271/comments"},"review_comment":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mathics/Mathics/pulls/271/commits"},"statuses":{"href":"https://api.github.com/repos/mathics/Mathics/statuses/bca5de1d2bd4ce80f537d6cf24df098194254d33"}}}}