{ "cells": [ { "cell_type": "markdown", "id": "7fbf07a8", "metadata": {}, "source": [ "(linalg_tutorial)=\n", "# Intro to the linear algebra module\n", "Most of the linear algebra module are wrappers with very few lines and an API nearly equal to their numpy counterpart. In general, the only thing you need to do is pass the input DataArray and indicate which dimensions\n", "correspond to the matrices. There are only a couple exceptions which have their own section." ] }, { "cell_type": "code", "execution_count": 1, "id": "f634cd80", "metadata": {}, "outputs": [], "source": [ "import xarray_einstats\n", "from xarray_einstats.tutorial import generate_matrices_dataarray" ] }, { "cell_type": "markdown", "id": "60f466a1", "metadata": {}, "source": [ "We start by generating syntetic data to work with:" ] }, { "cell_type": "code", "execution_count": 2, "id": "2d6947e2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim2: 4)> Size: 4kB\n", "0.7075 1.025 0.5685 0.8951 0.2065 3.384 ... 1.239 0.4527 0.5749 0.4766 0.859\n", "Dimensions without coordinates: batch, experiment, dim, dim2
<xarray.DataArray (batch: 10, experiment: 3)> Size: 240B\n", "4.854 4.74 4.457 2.637 2.79 3.163 1.998 ... 2.804 4.58 2.888 4.936 5.983 4.07\n", "Dimensions without coordinates: batch, experiment
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim2: 4)> Size: 4kB\n", "11.26 -2.363 -10.84 -0.2744 10.99 -2.017 ... -3.444 0.7703 0.316 0.01949 -1.162\n", "Dimensions without coordinates: batch, experiment, dim, dim2
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim2: 4)> Size: 4kB\n", "-0.5452 0.01652 -0.5624 -0.6214 -0.1592 ... -0.3322 -0.4013 0.2607 0.8128\n", "Dimensions without coordinates: batch, experiment, dim, dim2
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim2: 4)> Size: 4kB\n", "-1.298 -1.975 -1.858 -1.228 0.0 -3.137 ... -0.4307 1.052 0.0 0.0 0.0 -0.6995\n", "Dimensions without coordinates: batch, experiment, dim, dim2
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim2: 4)> Size: 4kB\n", "1.845 5.326 2.407 3.89 3.378 14.68 5.449 ... 5.586 6.55 1.279 1.373 1.791 2.658\n", "Dimensions without coordinates: batch, experiment, dim, dim2
<xarray.DataArray (dim: 4, dim2_bis: 4, batch_bis: 10, batch: 10, dim2: 4)> Size: 51kB\n", "10.79 3.926 1.503 3.986 0.1886 0.1844 ... 1.289 4.187 5.251 3.372 2.81 13.1\n", "Dimensions without coordinates: dim, dim2_bis, batch_bis, batch, dim2
<xarray.DataArray (dim: 4, dim2: 4, batch: 10, batch2: 10)> Size: 13kB\n", "10.79 0.1886 5.402 1.471 1.243 5.348 2.639 ... 3.462 3.618 11.21 9.47 4.187 13.1\n", "Dimensions without coordinates: dim, dim2, batch, batch2
<xarray.DataArray (batch: 10, experiment: 3, different_dim: 4, different_dim2: 4)> Size: 4kB\n", "0.7075 1.025 0.5685 0.8951 0.2065 3.384 ... 1.239 0.4527 0.5749 0.4766 0.859\n", "Dimensions without coordinates: batch, experiment, different_dim, different_dim2
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, different_dim2: 4)> Size: 4kB\n", "1.845 5.326 2.407 3.89 3.378 14.68 5.449 ... 5.586 6.55 1.279 1.373 1.791 2.658\n", "Dimensions without coordinates: batch, experiment, dim, different_dim2
<xarray.DataArray (dim: 4, dim2: 4, experiment: 3, experiment2: 3)> Size: 1kB\n", "9.727 6.68 3.595 6.68 18.66 6.065 3.595 ... 10.81 36.08 8.181 3.233 8.181 14.77\n", "Dimensions without coordinates: dim, dim2, experiment, experiment2
<xarray.DataArray (batch: 10, dim: 4, dim2: 4)> Size: 1kB\n", "4.487 3.158 0.9252 2.683 0.5319 3.799 ... 3.387 1.796 2.601 2.455 1.538 5.402\n", "Dimensions without coordinates: batch, dim, dim2
<xarray.DataArray (dim: 4, dim2: 4)> Size: 128B\n", "22.27 32.55 29.06 40.96 23.96 33.48 ... 25.27 29.59 34.97 20.57 34.89 30.26\n", "Dimensions without coordinates: dim, dim2
<xarray.DataArray (batch: 10, dim: 4, dim2: 4)> Size: 1kB\n", "10.79 3.543 0.4447 2.399 0.111 11.58 10.95 ... 5.104 1.799 2.513 3.052 0.79 13.1\n", "Dimensions without coordinates: batch, dim, dim2
<xarray.DataArray (dim: 4, dim2: 4, batch: 10, experiment: 3)> Size: 4kB\n", "33.15 44.26 22.52 1.318 1.76 0.8951 ... 19.52 36.93 18.42 42.62 80.64 40.23\n", "Dimensions without coordinates: dim, dim2, batch, experiment
<xarray.DataArray (dim: 4, dim2: 4)> Size: 128B\n", "496.0 1.06e+03 844.2 1.678e+03 573.9 ... 875.4 1.223e+03 423.1 1.218e+03 915.8\n", "Dimensions without coordinates: dim, dim2
<xarray.DataArray (dim: 4, dim2: 4)> Size: 128B\n", "32.03 68.57 42.6 101.0 40.06 76.88 59.44 ... 33.78 83.88 72.41 32.43 76.33 60.63\n", "Dimensions without coordinates: dim, dim2
<xarray.DataArray (dim: 4, dim2: 4)> Size: 128B\n", "32.03 68.57 42.6 101.0 40.06 76.88 59.44 ... 33.78 83.88 72.41 32.43 76.33 60.63\n", "Dimensions without coordinates: dim, dim2
<xarray.DataArray (batch: 10, experiment: 3, dim: 4)> Size: 960B\n", "2.676 19.38 0.8116 5.562 11.33 2.104 ... 6.259 12.24 6.737 0.5945 7.355 1.5\n", "Dimensions without coordinates: batch, experiment, dim
<xarray.DataArray (batch: 10, experiment: 3, dim: 4, dim_auto2: 4)> Size: 4kB\n", "2.676 6.135 1.302 3.007 6.135 19.38 2.018 ... 7.355 2.884 2.942 0.8866 2.884 1.5\n", "Dimensions without coordinates: batch, experiment, dim, dim_auto2
<xarray.DataArray (experiment: 3, dim: 4, dim2: 4, batch: 10, batch2: 10)> Size: 38kB\n", "0.5006 0.09001 0.1315 0.3874 0.5949 0.6645 ... 2.931 0.2908 0.5802 0.4342 0.7379\n", "Dimensions without coordinates: experiment, dim, dim2, batch, batch2