{"id":16705100,"url":"https://github.com/mcabbott/weightedarrays.jl","last_synced_at":"2026-01-02T12:16:46.465Z","repository":{"id":56054460,"uuid":"145140883","full_name":"mcabbott/WeightedArrays.jl","owner":"mcabbott","description":"Matrices with column weights","archived":false,"fork":false,"pushed_at":"2022-02-28T01:27:14.000Z","size":221,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-13T19:28:29.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcabbott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-17T16:05:23.000Z","updated_at":"2022-02-28T01:10:14.000Z","dependencies_parsed_at":"2022-08-15T12:20:16.118Z","dependency_job_id":null,"html_url":"https://github.com/mcabbott/WeightedArrays.jl","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FWeightedArrays.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FWeightedArrays.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FWeightedArrays.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FWeightedArrays.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcabbott","download_url":"https://codeload.github.com/mcabbott/WeightedArrays.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243561236,"owners_count":20311062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T19:28:40.230Z","updated_at":"2026-01-02T12:16:46.436Z","avatar_url":"https://github.com/mcabbott.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Weighted Arrays .jl\n\n[![Build Status](https://travis-ci.org/mcabbott/WeightedArrays.jl.svg?branch=master)](https://travis-ci.org/mcabbott/WeightedArrays.jl)\n\nThis simple package defines a `WeightedMatrix`, a struct with vector of weights corresponding to the columns of a matrix. By default the `weights(x)` add up to 1. The `array(x)` values may have a box constraint:\n```julia\njulia\u003e Weighted(randn(3,5))\nWeighted 3×5 Array{Float64,2}, of unclamped θ:\n -0.264476   -1.83297      0.0669732  -0.340433  -1.87672\n  0.0461253  -0.330401     0.0215189   2.3129    -1.78839\n  0.461376    0.00486523  -0.819182   -1.43221   -0.855756\nwith normalised weights p(θ), 5-element Array{Float64,1}:\n 0.2  0.2  0.2  0.2  0.2\n\njulia\u003e Weighted(rand(2,4), ones(4), 0, 1)\nWeighted 2×4 Array{Float64,2}, clamped 0.0 ≦ θ ≦ 1.0:\n 0.7842    0.257179  0.483388  0.780996\n 0.138967  0.748165  0.387104  0.167825\nwith normalised weights p(θ), 4-element Array{Float64,1}:\n 0.25  0.25  0.25  0.25\n```\nThese examples are roughly `wrandn(3,5)` and `wrand(2,4)`, there are also sub-random `sobol(3,7)` and regular `wgrid(2, 0:0.1:1)`.\nTheir values are mutable, `clamp!(x)` will enforce the box constraint, and `normalise!(x)` (with an s) the weights.\n\nThey are not subtypes of `AbstractArray`, but many functions will work.\nFor instance `x[1:2, :]` keeps only the first two rows (and the weights),\n`hcat(x,y)` will concatenate the weights,\nand `mapslices(f,x)` will act with `f` on columns \u0026 then restore weights.\n`sort(x)` re-arranges columns to order by the weights, `sortcols(x)` orders by the array instead,\n`unique(x)` will accumulate the weights of identical columns.\nA few functions like `log(x)` and `tanh(x)` act element-wise but update the box constraints appropriately.\n\nMost of this will work for any N-dimensional Array, not just a Matrix. The weights then belong to the last dimension.\n\n\u003cimg src=\"deps/red.png?raw=true\" width=\"440\" height=\"400\" alt=\"Plot example\" align=\"right\" padding=\"5\"\u003e\n\nPlot recipes are defined, in which the area of points indicating weight.\nThe example shown is a grid plus a bivariate sub-random normal distribution:\n\n```julia\njulia\u003e using Plots\n\njulia\u003e plot(wgrid(2, -5:5), m=:+)\n\njulia\u003e plot!(soboln(2, 2000), m=:diamond, c=:red)\n```\n\nWith more than three rows e.g. `plot(wrandn(4,50))`, it will plot the first two principal components (and attempt to scale these correctly).\nThere is a function `pplot(x)` which saves the PCA function (see help for `wPCA(x)`) in a global variable, so that `pplot!(t)` can add more points on the same axes.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Fweightedarrays.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcabbott%2Fweightedarrays.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Fweightedarrays.jl/lists"}