|
Cytnx
v0.7.2
|
linear algebra related functions. More...
Functions | |
| cytnx::UniTensor | Add (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise add More... | |
| template<class T > | |
| cytnx::UniTensor | Add (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Add (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Sub (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise subtract More... | |
| template<class T > | |
| cytnx::UniTensor | Sub (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Sub (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Mul (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise subtract More... | |
| template<class T > | |
| cytnx::UniTensor | Mul (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Mul (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Div (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise divide More... | |
| template<class T > | |
| cytnx::UniTensor | Div (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Div (const cytnx::UniTensor &Lt, const T &rc) |
| cytnx::UniTensor | Mod (const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt) |
| element-wise modulo More... | |
| template<class T > | |
| cytnx::UniTensor | Mod (const T &lc, const cytnx::UniTensor &Rt) |
| template<class T > | |
| cytnx::UniTensor | Mod (const cytnx::UniTensor &Lt, const T &rc) |
| std::vector< cytnx::UniTensor > | Svd (const cytnx::UniTensor &Tin, const bool &is_U=true, const bool &is_vT=true) |
| std::vector< cytnx::UniTensor > | Svd_truncate (const cytnx::UniTensor &Tin, const cytnx_uint64 &keepdim, const bool &is_U=true, const bool &is_vT=true) |
| std::vector< cytnx::UniTensor > | Hosvd (const cytnx::UniTensor &Tin, const std::vector< cytnx_uint64 > &mode, const bool &is_core=true, const bool &is_Ls=false, const std::vector< cytnx_int64 > &trucate_dim=std::vector< cytnx_int64 >()) |
| cytnx::UniTensor | ExpH (const cytnx::UniTensor &Tin, const double &a=1, const double &b=0) |
| cytnx::UniTensor | ExpM (const cytnx::UniTensor &Tin, const double &a=1, const double &b=0) |
| cytnx::UniTensor | Trace (const cytnx::UniTensor &Tin, const cytnx_int64 &a, const cytnx_int64 &b, const bool &by_label=false) |
| std::vector< cytnx::UniTensor > | Qr (const cytnx::UniTensor &Tin, const bool &is_tau=false) |
| std::vector< cytnx::UniTensor > | Qdr (const cytnx::UniTensor &Tin, const bool &is_tau=false) |
| UniTensor | Pow (const UniTensor &Tin, const double &p) |
| take power p on all the elements in UniTensor. More... | |
| void | Pow_ (UniTensor &Tin, const double &p) |
| inplace perform power on all the elements in UniTensor. More... | |
| Tensor | Add (const Tensor &Lt, const Tensor &Rt) |
| template<class T > | |
| Tensor | Add (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Add (const Tensor &Lt, const T &rc) |
| Tensor | Sub (const Tensor &Lt, const Tensor &Rt) |
| element-wise subtract More... | |
| template<class T > | |
| Tensor | Sub (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Sub (const Tensor &Lt, const T &rc) |
| Tensor | Mul (const Tensor &Lt, const Tensor &Rt) |
| element-wise subtract More... | |
| template<class T > | |
| Tensor | Mul (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Mul (const Tensor &Lt, const T &rc) |
| Tensor | Div (const Tensor &Lt, const Tensor &Rt) |
| element-wise divide More... | |
| template<class T > | |
| Tensor | Div (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Div (const Tensor &Lt, const T &rc) |
| Tensor | Mod (const Tensor &Lt, const Tensor &Rt) |
| element-wise divide More... | |
| template<class T > | |
| Tensor | Mod (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Mod (const Tensor &Lt, const T &rc) |
| Tensor | Cpr (const Tensor &Lt, const Tensor &Rt) |
| element-wise compare More... | |
| template<class T > | |
| Tensor | Cpr (const T &lc, const Tensor &Rt) |
| template<class T > | |
| Tensor | Cpr (const Tensor &Lt, const T &rc) |
| Tensor | Norm (const Tensor &Tl) |
| calculate the norm of a tensor. More... | |
| Tensor | Det (const Tensor &Tl) |
| calculate the determinant of a tensor. More... | |
| std::vector< Tensor > | Svd (const Tensor &Tin, const bool &is_U=true, const bool &is_vT=true) |
| Perform Singular-Value decomposition on a rank-2 Tensor. More... | |
| std::vector< Tensor > | Svd_truncate (const Tensor &Tin, const cytnx_uint64 &keepdim, const bool &is_U=true, const bool &is_vT=true) |
| std::vector< Tensor > | Hosvd (const Tensor &Tin, const std::vector< cytnx_uint64 > &mode, const bool &is_core=true, const bool &is_Ls=false, const std::vector< cytnx_int64 > &trucate_dim=std::vector< cytnx_int64 >()) |
| std::vector< Tensor > | Qr (const Tensor &Tin, const bool &is_tau=false) |
| Perform QR decomposition on a rank-2 Tensor. More... | |
| std::vector< Tensor > | Qdr (const Tensor &Tin, const bool &is_tau=false) |
| Perform QDR decomposition on a rank-2 Tensor. More... | |
| std::vector< Tensor > | Eigh (const Tensor &Tin, const bool &is_V=true, const bool &row_v=false) |
| eigen-value decomposition for Hermitian matrix More... | |
| std::vector< Tensor > | Eig (const Tensor &Tin, const bool &is_V=true, const bool &row_v=false) |
| eigen-value decomposition for generic square matrix More... | |
| Tensor | Trace (const Tensor &Tn, const cytnx_uint64 &axisA=0, const cytnx_uint64 &axisB=1) |
| perform trace over index. More... | |
| Tensor | Min (const Tensor &Tn) |
| get the minimum element. More... | |
| Tensor | Max (const Tensor &Tn) |
| get the maximum element. More... | |
| Tensor | Sum (const Tensor &Tn) |
| get the sum of all the elements. More... | |
| Tensor | Matmul (const Tensor &TL, const Tensor &TR) |
| perform matrix multiplication on two tensors. More... | |
| Tensor | Matmul_dg (const Tensor &Tl, const Tensor &Tr) |
| perform matrix multiplication on two Tensors with one rank-1 and the other rank-2 where the rank-1 represent the diagonal elements of the specific tensor. More... | |
| Tensor | InvM (const Tensor &Tin) |
| Matrix inverse. More... | |
| void | InvM_ (Tensor &Tin) |
| inplace perform Matrix inverse. More... | |
| Tensor | Inv (const Tensor &Tin, const double &clip) |
| Element-wise inverse with clip. More... | |
| void | Inv_ (Tensor &Tin, const double &clip) |
| inplace perform Element-wise inverse with clip. More... | |
| Tensor | Conj (const Tensor &Tin) |
| Conjugate all the element in Tensor. More... | |
| void | Conj_ (Tensor &Tin) |
| inplace perform Conjugate on all the element in Tensor. More... | |
| Tensor | Exp (const Tensor &Tin) |
| Exponential all the element in Tensor. More... | |
| Tensor | Expf (const Tensor &Tin) |
| Exponential all the element in Tensor. More... | |
| void | Exp_ (Tensor &Tin) |
| inplace perform Exponential on all the element in Tensor. More... | |
| void | Expf_ (Tensor &Tin) |
| inplace perform Exponential on all the element in Tensor. More... | |
| Tensor | Pow (const Tensor &Tin, const double &p) |
| take power p on all the elements in Tensor. More... | |
| void | Pow_ (Tensor &Tin, const double &p) |
| inplace perform power on all the elements in Tensor. More... | |
| Tensor | Abs (const Tensor &Tin) |
| Elementwise absolute value. More... | |
| void | Abs_ (Tensor &Tin) |
| inplace perform elementwiase absolute value. More... | |
| Tensor | Diag (const Tensor &Tin) |
| return a diagonal tensor with diagonal elements provided as Tin. More... | |
| Tensor | Tensordot (const Tensor &Tl, const Tensor &Tr, const std::vector< cytnx_uint64 > &idxl, const std::vector< cytnx_uint64 > &idxr, const bool &cacheL=false, const bool &cacheR=false) |
| perform tensor dot by sum out the indices assigned of two Tensors. More... | |
| Tensor | Tensordot_dg (const Tensor &Tl, const Tensor &Tr, const std::vector< cytnx_uint64 > &idxl, const std::vector< cytnx_uint64 > &idxr, const bool &diag_L) |
| perform tensor dot by sum out the indices assigned of two Tensors, with either one of them to be a rank-2 diagonal tensor represented by a rank-2 tensor. More... | |
| Tensor | Outer (const Tensor &Tl, const Tensor &Tr) |
| perform outer produces of two rank-1 Tensor. More... | |
| Tensor | Kron (const Tensor &Tl, const Tensor &Tr, const bool &Tl_pad_left=false, const bool &Tr_pad_left=false) |
| perform kronecker produces of two Tensor. More... | |
| Tensor | Vectordot (const Tensor &Tl, const Tensor &Tr, const bool &is_conj=false) |
| perform inner product of vectors More... | |
| Tensor | Dot (const Tensor &Tl, const Tensor &Tr) |
| dot product of two arrays. More... | |
| std::vector< Tensor > | Tridiag (const Tensor &Diag, const Tensor &Sub_diag, const bool &is_V=true, const bool &is_row=false) |
| perform diagonalization of symmetric tri-diagnoal matrix. More... | |
| Tensor | ExpH (const Tensor &in, const cytnx_double &a=1, const cytnx_double &b=0) |
| perform matrix exponential for Hermitian matrix More... | |
| Tensor | ExpM (const Tensor &in, const cytnx_double &a=1, const cytnx_double &b=0) |
| perform matrix exponential for generic matrix More... | |
| std::vector< Tensor > | Lanczos_ER (LinOp *Hop, const cytnx_uint64 &k=1, const bool &is_V=true, const cytnx_uint64 &maxiter=10000, const double &CvgCrit=1.0e-14, const bool &is_row=false, const Tensor &Tin=Tensor(), const cytnx_uint32 &max_krydim=4, const bool &verbose=false) |
| perform Lanczos for hermitian/symmetric matrices or linear function. More... | |
| std::vector< Tensor > | Lanczos_Gnd (LinOp *Hop, const double &CvgCrit=1.0e-14, const bool &is_V=true, const Tensor &Tin=Tensor(), const bool &verbose=false, const unsigned int &Maxiter=100000) |
| perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value More... | |
| std::vector< Tensor > | Lstsq (const Tensor &A, const Tensor &b, const float &rcond=-1) |
| Return the least-squares solution to a linear matrix equation. More... | |
linear algebra related functions.
| void cytnx::linalg::Abs_ | ( | Tensor & | Tin | ) |
inplace perform elementwiase absolute value.
| Tin,the | input Tensor. |
description: on return, the elements in Tin will be modified to it's absolute value. Note that if the input tensor is complex, it will be modified to real type.
| cytnx::UniTensor cytnx::linalg::Add | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise add
| cytnx::UniTensor cytnx::linalg::Add | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Add | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| void cytnx::linalg::Conj_ | ( | Tensor & | Tin | ) |
| cytnx::UniTensor cytnx::linalg::Div | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise divide
| cytnx::UniTensor cytnx::linalg::Div | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Div | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
dot product of two arrays.
description:
[Note] performance tune: This function have better performance when two arrays with same types, and are one of following type: cytnx_double, cytnx_float, cytnx_complex64 or cytnx_complex128.
[Python] In Python API, operator@ is overloaded as a shorthand of linalg::Dot.
| void cytnx::linalg::Exp_ | ( | Tensor & | Tin | ) |
inplace perform Exponential on all the element in Tensor.
| Tin,the | input Tensor. |
description:
| void cytnx::linalg::Expf_ | ( | Tensor & | Tin | ) |
inplace perform Exponential on all the element in Tensor.
| Tin,the | input Tensor. |
description:
| cytnx::UniTensor cytnx::linalg::ExpH | ( | const cytnx::UniTensor & | Tin, |
| const double & | a = 1 , |
||
| const double & | b = 0 |
||
| ) |
| Tensor cytnx::linalg::ExpH | ( | const Tensor & | in, |
| const cytnx_double & | a = 1 , |
||
| const cytnx_double & | b = 0 |
||
| ) |
| cytnx::UniTensor cytnx::linalg::ExpM | ( | const cytnx::UniTensor & | Tin, |
| const double & | a = 1 , |
||
| const double & | b = 0 |
||
| ) |
| Tensor cytnx::linalg::ExpM | ( | const Tensor & | in, |
| const cytnx_double & | a = 1 , |
||
| const cytnx_double & | b = 0 |
||
| ) |
| std::vector<cytnx::UniTensor> cytnx::linalg::Hosvd | ( | const cytnx::UniTensor & | Tin, |
| const std::vector< cytnx_uint64 > & | mode, | ||
| const bool & | is_core = true , |
||
| const bool & | is_Ls = false , |
||
| const std::vector< cytnx_int64 > & | trucate_dim = std::vector< cytnx_int64 >() |
||
| ) |
| std::vector<Tensor> cytnx::linalg::Hosvd | ( | const Tensor & | Tin, |
| const std::vector< cytnx_uint64 > & | mode, | ||
| const bool & | is_core = true , |
||
| const bool & | is_Ls = false , |
||
| const std::vector< cytnx_int64 > & | trucate_dim = std::vector< cytnx_int64 >() |
||
| ) |
Element-wise inverse with clip.
description: Performs Elementwise inverse with clip. if A[i] < clip, then 1/A[i] = 0 will be set.
[Note] For complex type Tensors, the square norm is used to determine the clip.
| void cytnx::linalg::Inv_ | ( | Tensor & | Tin, |
| const double & | clip | ||
| ) |
inplace perform Element-wise inverse with clip.
description:
[Note] For complex type Tensors, the square norm is used to determine the clip.
| void cytnx::linalg::InvM_ | ( | Tensor & | Tin | ) |
inplace perform Matrix inverse.
description: on return, the Tin will be modified to it's inverse.
[Note] the Tin should be a rank-2 Tensor.
| Tensor cytnx::linalg::Kron | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const bool & | Tl_pad_left = false , |
||
| const bool & | Tr_pad_left = false |
||
| ) |
perform kronecker produces of two Tensor.
| Tl | rank-n Tensor #1 |
| Tr | rank-m Tensor #2 |
| Tl_pad_left | The padding scheme for Tl if Tl.rank != Tr.rank |
| Tr_pad_left | The padding scheme for Tr if Tl.rank != Tr.rank |
description: The function assume two tensor has the same rank. In case where two tensors have different ranks, the small one will be extend by adding redundant dimension to the beginning of axis (T<x>_pad_right=true) or by adding redundant dim to the last axis (if T<x>_pad_left=false [default]). if the Tensor #1 has shape=(i1,j1,k1,l1...), and Tensor #2 has shape=(i2,j2,k2,l2...); then the return Tensor will have shape=(i1*i2,j1*j2,k1*k2...)
[Note] two tensor should on same device.
| std::vector<Tensor> cytnx::linalg::Lanczos_ER | ( | LinOp * | Hop, |
| const cytnx_uint64 & | k = 1 , |
||
| const bool & | is_V = true , |
||
| const cytnx_uint64 & | maxiter = 10000 , |
||
| const double & | CvgCrit = 1.0e-14 , |
||
| const bool & | is_row = false , |
||
| const Tensor & | Tin = Tensor() , |
||
| const cytnx_uint32 & | max_krydim = 4 , |
||
| const bool & | verbose = false |
||
| ) |
perform Lanczos for hermitian/symmetric matrices or linear function.
| Hop | the Linear Operator defined by LinOp class or it's inheritance (see LinOp). |
| k | the number of lowest k eigen values. |
| is_V | if set to true, the eigen vectors will be returned. |
| maxiter | the maximum interation steps for each k. |
| CvgCrit | the convergence criterion of the energy. |
| is_row | whether the return eigen vectors should be in row-major form. |
| Tin | the initial vector, this should be rank-1 |
| max_krydim | the maximum krylov subspace dimension for each iteration. |
| verbose | print out iteration info. |
#description: This function calculate the eigen value problem using explicitly restarted Lanczos.
#Performance tune: For small linear dimension, try to reduce max_krydim.
#[Note] To use, define a linear operator with LinOp class either by assign a custom function or create a class that inherit LinOp (see LinOp for further details)
| std::vector<Tensor> cytnx::linalg::Lanczos_Gnd | ( | LinOp * | Hop, |
| const double & | CvgCrit = 1.0e-14 , |
||
| const bool & | is_V = true , |
||
| const Tensor & | Tin = Tensor() , |
||
| const bool & | verbose = false , |
||
| const unsigned int & | Maxiter = 100000 |
||
| ) |
perform Lanczos for hermitian/symmetric matrices or linear function to get ground state and lowest eigen value
| Hop | the Linear Operator defined by LinOp class or it's inheritance (see LinOp). |
| CvgCrit | the convergence criterion of the energy. |
| is_V | if set to true, the eigen vectors will be returned. |
| Tin | the initial vector, this should be rank-1 |
| verbose | print out iteration info. |
| maxiter | the maximum interation steps for each k. |
#description: This function calculate the eigen value problem using naive Lanczos to get ground state and lowest eigen value.
#[Note] To use, define a linear operator with LinOp class either by assign a custom function or create a class that inherit LinOp (see LinOp for further details)
| std::vector<Tensor> cytnx::linalg::Lstsq | ( | const Tensor & | A, |
| const Tensor & | b, | ||
| const float & | rcond = -1 |
||
| ) |
Return the least-squares solution to a linear matrix equation.
| A | “Coefficient” matrix, must be two-dimensional. |
| b | Ordinate or “dependent variable” values, must be two-dimensional, the least-squares solution is calculated for each of the K columns of b. |
| rcond | Cut-off ratio for small singular values of a. For the purposes of rank determination, singular values are treated as zero if they are smaller than rcond times the largest singular value of A, If it is negative, the machine precision is used. |
1. the first tensor is least-squares solutions in the K columns. 2. the second tensor is the sums of squared residuals: Squared Euclidean 2-norm for each column in b - a @ x. If the rank of a is < N or M <= N, this is a zero Tensor. 3. the third tensor is the rank of matrix A. 4. the forth tensor is singular values of A.
#description: Computes the vector x that approximatively solves the equation A @ x = b. The equation may be under-, well-, or over-determined independent columns. If a is square and of full rank, then x (but for round-off error) is the “exact” solution of the equation. Else, x minimizes the Euclidean 2-norm || b - a x ||.
[Ke]
perform matrix multiplication on two tensors.
[Note] the TL and TR should be both rank-2 Tensor.
get the maximum element.
[Note] For complex TN, only real part is compared.
get the minimum element.
[Note] For complex TN, only real part is compared.
| cytnx::UniTensor cytnx::linalg::Mod | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise modulo
| cytnx::UniTensor cytnx::linalg::Mod | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mod | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mul | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise subtract
| cytnx::UniTensor cytnx::linalg::Mul | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Mul | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| void cytnx::linalg::Pow_ | ( | UniTensor & | Tin, |
| const double & | p | ||
| ) |
| void cytnx::linalg::Pow_ | ( | Tensor & | Tin, |
| const double & | p | ||
| ) |
| std::vector<cytnx::UniTensor> cytnx::linalg::Qdr | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_tau = false |
||
| ) |
Perform QDR decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_tau | if return the tau that contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors |
1. the first tensor is the orthomormal matrix [Q], a 2-d tensor (matrix) 2. the second tensor is the diagonal matrix [D], a 1-d tensor (matrix). 3. the third tensor is the right-upper triangular matrix [R], a 2-d tensor (matrix). 4. the forth tensor is the Householder reflectors [H], a 1-d tensor (matrix). It only return when is_tau=true.
| std::vector<cytnx::UniTensor> cytnx::linalg::Qr | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_tau = false |
||
| ) |
Perform QR decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_tau | if return the tau that contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors |
1. the first tensor is the orthomormal matrix [Q], a 2-d tensor (matrix) 2. the second tensor is the right-upper triangular matrix [R], a 2-d tensor (matrix). 3. the third tensor is the Householder reflectors [H], a 1-d tensor (matrix). It only return when is_tau=true.
| cytnx::UniTensor cytnx::linalg::Sub | ( | const cytnx::UniTensor & | Lt, |
| const cytnx::UniTensor & | Rt | ||
| ) |
element-wise subtract
| cytnx::UniTensor cytnx::linalg::Sub | ( | const T & | lc, |
| const cytnx::UniTensor & | Rt | ||
| ) |
| cytnx::UniTensor cytnx::linalg::Sub | ( | const cytnx::UniTensor & | Lt, |
| const T & | rc | ||
| ) |
| std::vector<cytnx::UniTensor> cytnx::linalg::Svd | ( | const cytnx::UniTensor & | Tin, |
| const bool & | is_U = true , |
||
| const bool & | is_vT = true |
||
| ) |
| std::vector<Tensor> cytnx::linalg::Svd | ( | const Tensor & | Tin, |
| const bool & | is_U = true , |
||
| const bool & | is_vT = true |
||
| ) |
Perform Singular-Value decomposition on a rank-2 Tensor.
| Tin | a Tensor , it should be a rank-2 tensor (matrix) |
| is_U | if return a left uniform matrix. |
| is_vT | if return a right uniform matrix. |
1. the first tensor is a 1-d tensor contanin the singular values 2. the second tensor is the left uniform matrix [U], a 2-d tensor (matrix). It only return when is_U=true. 3. the third tensor is the right uniform matrix [vT], a 2-d tensor (matrix). It only return when is_vT=true.
| std::vector<cytnx::UniTensor> cytnx::linalg::Svd_truncate | ( | const cytnx::UniTensor & | Tin, |
| const cytnx_uint64 & | keepdim, | ||
| const bool & | is_U = true , |
||
| const bool & | is_vT = true |
||
| ) |
| std::vector<Tensor> cytnx::linalg::Svd_truncate | ( | const Tensor & | Tin, |
| const cytnx_uint64 & | keepdim, | ||
| const bool & | is_U = true , |
||
| const bool & | is_vT = true |
||
| ) |
| Tensor cytnx::linalg::Tensordot | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const std::vector< cytnx_uint64 > & | idxl, | ||
| const std::vector< cytnx_uint64 > & | idxr, | ||
| const bool & | cacheL = false , |
||
| const bool & | cacheR = false |
||
| ) |
perform tensor dot by sum out the indices assigned of two Tensors.
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| idxl | the indices of rank of Tensor #1 that is going to sum with Tensor #2 |
| idxr | the indices of rank of Tensor #2 that is going to sum with Tensor #1 |
| cacheL | cache Tensor #1 (See user-guide for details) |
| cacheR | cache Tensor #2 (See user-guide for details) |
[Note]
| Tensor cytnx::linalg::Tensordot_dg | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const std::vector< cytnx_uint64 > & | idxl, | ||
| const std::vector< cytnx_uint64 > & | idxr, | ||
| const bool & | diag_L | ||
| ) |
perform tensor dot by sum out the indices assigned of two Tensors, with either one of them to be a rank-2 diagonal tensor represented by a rank-2 tensor.
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| idxl | the indices of rank of Tensor #1 that is going to sum with Tensor #2 |
| idxr | the indices of rank of Tensor #2 that is going to sum with Tensor #1 |
| diag_L | if Tl(true)/Tr(false) is a diagnal matrix, represented by a rank-1 tensor. |
[Note]
| cytnx::UniTensor cytnx::linalg::Trace | ( | const cytnx::UniTensor & | Tin, |
| const cytnx_int64 & | a, | ||
| const cytnx_int64 & | b, | ||
| const bool & | by_label = false |
||
| ) |
| Tensor cytnx::linalg::Trace | ( | const Tensor & | Tn, |
| const cytnx_uint64 & | axisA = 0 , |
||
| const cytnx_uint64 & | axisB = 1 |
||
| ) |
perform trace over index.
[Note] the Tn should be at-least rank-2 Tensor.
| std::vector<Tensor> cytnx::linalg::Tridiag | ( | const Tensor & | Diag, |
| const Tensor & | Sub_diag, | ||
| const bool & | is_V = true , |
||
| const bool & | is_row = false |
||
| ) |
perform diagonalization of symmetric tri-diagnoal matrix.
| Diag | Tensor #1 |
| Sub_diag | Tensor #2 |
| is_V | if calculate the eigen value. |
| k | Return k lowest eigen vector if is_V=True |
description: two Tensors must be Rank-1, with length of Diag = L and Sub_diag length = L-1.
[Note] performance tune: This function have better performance when two vectors with same types, and are one of following type: cytnx_double, cytnx_float. In general all real type can be use as input, which will be promote to floating point type for calculation.
| Tensor cytnx::linalg::Vectordot | ( | const Tensor & | Tl, |
| const Tensor & | Tr, | ||
| const bool & | is_conj = false |
||
| ) |
perform inner product of vectors
| Tl | Tensor #1 |
| Tr | Tensor #2 |
| if | the Tl should be conjugated (only work for complex. For real Tensor, no function), default: false |
description: two Tensors must be Rank-1, with same length.
[Note] performance tune: This function have better performance when two vectors with same types, and are one of following type: cytnx_double, cytnx_float, cytnx_complex64 or cytnx_complex128.


Photo Gallery
By Sebastian Ramirez-Brunner
Name:
{{image.name}}
Location:
{{image.location}}
Date:
{{image.date}}
All photos taken by and property of Sebastian Ramirez-Brunner


The University of California, San Diego will honor World AIDS Day all week with a variety of free, public events, including a
viewing of portions of the AIDS Memorial Quilt. World AIDS Day is honored every year on December 1st. This year’s events reflect the
“Hands Up for HIV Prevention” theme, language symbolic of the global community effort needed to reinvigorate communities, repower #HIVprevention, and reduce infection rates. Please continue to check back for updated information.#ucsdAIDS16
Interested in joining the UC San Diego World AIDS Day Planning Committee? Click here
Recaps of Past UCSD World AIDS DaysWorld AIDS Day 2009 World AIDS Day 2010 World AIDS Day 2011 World AIDS Day 2012 World AIDS Day Gallery |


In programming, there are multiple paradigms that are the result of various approaches to decomposing and solving problems. Two of these are functional and object-oriented programming.
The fundamental difference between these two paradigms is in their names, but it can take some time to fully understand them. Functional programming solves problem by using functions that perform various operations, while the object-oriented approach uses objects of various classes to give behavior to the data they contain.
One thing that this means is that the data in object-oriented programming is mutable based upon the attributes of its class. This stands in opposition to functional programming, where data can only be changed by a function.


Demo Environment More options *Account Help Please provide the subdomain of your Interaction Studio Learning Account *Dataset Please provide the name of the Interaction Studio Dataset
Build your User Events *User ID Known Anonymous Add Catalog Action Row Add Custom Event Row Duplicate Row Submit Loading Catalog Type Product Article Blog Category Item ID Action Type Help To have multiple products in a "Purchase", create multiple rows with the same value in the Datetime View Item View Time Purchase Number Help Quantity should be an integer, and Price should be the Item Price without the dollar sign Please enter only numbers into the Action Num field Datetime Format: 01 Jan 2020 12:34:56 Delete Condition Action Name Optional Attributes Help To have these attributes appear in your UCP, ensure you've created the Attributes first in your IS dataset -> Setup Datetime Delete Condition


Revature Reimbursement
New Reimbursement
Amount:
Notes:
Submit
Reimbursements
Category
My Notes
Amount
Status
Reimbursement Details
×
Amount:
$200
Category:
category name
Notes:
Somenotes Here
Comment:


| influencePlot {car} | R Documentation |
This function creates a “bubble” plot of Studentized residuals versus hat values, with the areas of the circles representing the observations proportional to the value Cook's distance. Vertical reference lines are drawn at twice and three times the average hat value, horizontal reference lines at -2, 0, and 2 on the Studentized-residual scale.
influencePlot(model, ...) ## S3 method for class 'lm' influencePlot(model, scale=10, xlab="Hat-Values", ylab="Studentized Residuals", id=TRUE, ...) ## S3 method for class 'lmerMod' influencePlot(model, ...)
model |
a linear, generalized-linear, or linear mixed model; the |
scale |
a factor to adjust the size of the circles. |
xlab, ylab |
axis labels. |
id |
settings for labelling points; see |
... |
arguments to pass to the |
If points are identified, returns a data frame with the hat values, Studentized residuals and Cook's distance of the identified points. If no points are identified, nothing is returned. This function is primarily used for its side-effect of drawing a plot.
John Fox<EMAIL_ADDRESS>minor changes by S. Weisberg<EMAIL_ADDRESS>Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
cooks.distance
, rstudent
,
hatvalues
, showLabels
influencePlot(lm(prestige ~ income + education, data=Duncan)) ## Not run: influencePlot(lm(prestige ~ income + education, data=Duncan), id=list(method="identify")) ## End(Not run)


Since we've installed a SSL certificate on our server to improve security, with forcing https for all our sites and download, we've encountered a problem for some user's of Avast while installing our BBLog addon.
Avast have a feature called "Enable HTTPS scanning", this means that they scan and decrypt the encrypted https traffic. This feature have many "false-positive" matches. A more detailed view and workaround here:
https://forum.avast.com/index.php?topic=175302.0
BBLog is not the only site and service the have problems with the "special feature" from avast.
We can nothing do against this errors, the best is to just disable HTTPS scanning for the download of our addon.


My Project
Main Page
Packages
Classes
Class List
Class Index
Class Hierarchy
Class Members
Class Hierarchy
Go to the textual class hierarchy
Generated by
1.8.11


Before Change
@staticmethod
def _standard_distance(mean_distance, sum_squared_distance):
with np.errstate(divide="ignore", invalid="ignore"):
st_dist = np.sqrt(np.divide(sum_squared_distance, np.fabs(mean_distance)))
return st_dist
@staticmethod
After Change
@staticmethod
def _standard_distance(cardinality, sum_squared_distance):
with np.errstate(divide="ignore", invalid="ignore"):
st_dist = np.array([np.sqrt(i) for i in np.divide(sum_squared_distance, cardinality)])
return st_dist
@staticmethod


There is a movement afoot for contra callers to use gender neutral terms for dance roles. Perhaps you have already experienced a dance, an evening or a whole weekend of non gendered calling at Contra Remix, Next Gen dance camp, or Supersonic. On May 4th & May 11th, callers at Fulton will be calling “larks & ravens” instead of “gents & ladies,” giving our community an opportunity to experiment with a new model and further community dialog about why and if we should pursue this evolution in contra dancing. The contra committee welcomes feedback from all dancers about their experiences at these upcoming dances. We will have surveys available at the dances. Additionally, please talk to us personally or send an email to<EMAIL_ADDRESS>What’s wrong with “Gents & Ladies?”
There are numerous benefits of not adhering to strict gender roles at contra dances:
For many reasons, our contra dances are seeing increased numbers of people who dance both roles, dance with partners of the same gender, and dance in roles that do not match their gender presentation. At “gents & ladies” dances, newer dancers can be confused by all this non-conformity as the terms “gents” and “ladies” no longer reflect the reality of what they’re encountering on the dance floor. The problem is not that a dancer is dancing the “wrong” role; the problem is that the term used to describe the role no longer represents the reality of the dance. By taking gender out of the language, dancers are freed from social pressure to adhere to one role over another, and far less likely to receive unpleasant comments from other dancers that they are in the “wrong” place.
But Why “Larks & Ravens?”
Larks=Left, Ravens=Right
As dance communities across the country explore this shift in culture, there have been a number of gender neutral alternatives proposed. The contra committee does not endorse any particular terms, but “larks & ravens” has significant momentum nationwide and for this reason, we feel it makes sense to use these terms for our upcoming non gendered dance. For now, we ask that deliberations about which particular non gendered words to use are saved for another time, as these opinions can easily derail the conversation about why we might consider shifting to non gendered terms.
Open Minds & Hearts
Change can be hard, especially when it involves something near and dear to our hearts, as contra dancing is for many of us. As we embark upon this experiment, we kindly ask that everyone come to these dances with an open mind, an open heart, lighthearted curiosity, and a desire to challenge ourselves with something new. We will all make mistakes, and that’s ok! We hope that you will try it out, reflect on what it means to you, and contribute to the discussion. To read more about the movement towards non gendered contra dance roles, including a personal essay on why it’s important, a history of alternative names and lessons gleaned from other communities, explore here: http://contra.maiamccormick.com/larks-and-ravens.html
Time and Place
Saturday May 4 - The Stage Crew with Isaac Banner calling
Saturday May 11 - Meriweather with Noah Grunzweig calling
7:30pm lesson | 8-11 dance | $6-15 sliding scale
Fulton Park Community Center, 68 SW Miles St in Portland


{% extends 'flamingo/base.html' %} {% block content %}
| First Name | Last Name | Organisations | ||
|---|---|---|---|---|
| {{ user.first_name }} | {{ user.last_name }} | {{ user.email }} |
{% for membership in user.memberships.all %}
{{ membership.organisation }} {% endfor %} |
Link |
No members were found matching this search
{% endif %} {% if is_paginated %} {% endif %} Didn't find the member? Add them to Everproof Back {% endblock %}


--- layout: default title: samplejs ---
Welcome to samplejs - a simple reference site for those new to JavaScript.
Why not start with a brief history of the language, or check out our list of JavaScript resources and samples.


Address:- 8 Julliette Avenue, Punchbowl.
During late 1980's early 1990's I spoke to Aunty Alice quite a couple of times about the family history, she seemed a lonely lady. I also went over to Rookwood Cemetry & photoed her parents grave for her, it is red marble & in very good condition, just behind the Anglican Chapel. She also told me her husbands ashes were scattered at St Barnabas Church Punchbowl where she could go & visit him there. The family were worried about her being on her own & moved her up to Norah Head Nursing Home where she died.
Wednesday 1st Oct.2003, John & Margaret Brookfield went to Aunty Alice's funeral service at Mackay Family Crematorium, Pacific Highway, Palmdale, then afterwards to their home & met all of Elva Blairs family. Aunty Ellen Geach was also there.
October 2003, John received a letter from Elva thanking them for going to the Funeral.
SMH - NEWELL, Alice May (nee Brookfield) - 28 September, 2003, at Norah Heads Nursing Home, late of Punshbowl. Devoted wife of Russ (dec), beloved sister of Elva, & sister-in-law of Jim (dec), loving Aunt of Sue, Janine & family. Loved sister-in-law of Beryl & Ed & aunt of Ray, Valerie & Bruce & their families. Aged 88years.
The rels & friends of Alice are invited to her funeral service, to-morrow Wednesday, at 1pm in the Chapel of Mackay Family Crematorium, Pacific Highway, Palmdale.


Some Vue Mashup Examples
Basic Google Map Example
Plot Recent Earthquakes on Google Map
Explore Movies and Their Trailers


{% verbatim %}
Neural network framework often provides symbolic API for users to write network topology conveniently. This doc manily focus on symbolic API in most popular neural network frameworks, and try to find out how to parse symbolic configuration to a portable file, such as protobuf or json.
The core concept of symbolic API is Symbol
. Mxnet implements Symbol
class in C++, and export to Python using C-API. Please refer to the comments in Mxnet:
Symbol
is help class used to represent the operator node in Graph.
Symbol
acts as an interface for building graphs from different components like Variable, Functor and Group. Symbol
is also exported to python front-end (while Graph is not) to enable quick test and deployment. Conceptually, symbol is the final operation of a graph and thus including all the information required (the graph) to evaluate its output value.
A simple network topology wrote by Symbol is as follows:
def get_symbol(num_classes=10, **kwargs):
data = mx.symbol.Variable('data')
data = mx.symbol.Flatten(data=data)
fc1 = mx.symbol.FullyConnected(data = data, name='fc1', num_hidden=128)
act1 = mx.symbol.Activation(data = fc1, name='relu1', act_type="relu")
fc2 = mx.symbol.FullyConnected(data = act1, name = 'fc2', num_hidden = 64)
act2 = mx.symbol.Activation(data = fc2, name='relu2', act_type="relu")
fc3 = mx.symbol.FullyConnected(data = act2, name='fc3', num_hidden=num_classes)
mlp = mx.symbol.SoftmaxOutput(data = fc3, name = 'softmax')
return mlp
Varible here is actually a Symbol. Every basic Symbol will correspond to one Node, and every Node has its own NodeAttr. There is a op field in NodeAttr class, when a Symbol represents Variable(often input data), the op field is null.
Symbol contains a data member, std::vector
And Symbol can be saved to a Json file.
Here is a detailed example:
>>> import mxnet as mx
>>> data = mx.symbol.Variable('data')
>>> print data.debug_str()
Variable:data
>>> data = mx.symbol.Flatten(data=data)
>>> print data.debug_str()
Symbol Outputs:
output[0]=flatten0(0)
Variable:data
--------------------
Op:Flatten, Name=flatten0
Inputs:
arg[0]=data(0) version=0
>>> fc1 = mx.symbol.FullyConnected(data = data, name='fc1', num_hidden=128)
>>> print fc1.debug_str()
Symbol Outputs:
output[0]=fc1(0)
Variable:data
--------------------
Op:Flatten, Name=flatten0
Inputs:
arg[0]=data(0) version=0
Variable:fc1_weight
Variable:fc1_bias
--------------------
Op:FullyConnected, Name=fc1
Inputs:
arg[0]=flatten0(0)
arg[1]=fc1_weight(0) version=0
arg[2]=fc1_bias(0) version=0
Attrs:
num_hidden=128
The core concept of symbolic API is Tensor
. Tensorflow defines Tensor
in Python. Please refer to the comments in TensorFlow:
A Tensor
is a symbolic handle to one of the outputs of an Operation
. It does not hold the values of that operation's output, but instead provides a means of computing those values in a TensorFlow Session.
A simple example is as follows:
# Build a dataflow graph.
c = tf.constant([[1.0, 2.0], [3.0, 4.0]])
d = tf.constant([[1.0, 1.0], [0.0, 1.0]])
e = tf.matmul(c, d)
# Construct a `Session` to execute the graph.
sess = tf.Session()
# Execute the graph and store the value that `e` represents in `result`.
result = sess.run(e)
The main method of Tensor
is as follows:
@property
def op(self):
"""The `Operation` that produces this tensor as an output."""
return self._op
@property
def dtype(self):
"""The `DType` of elements in this tensor."""
return self._dtype
@property
def graph(self):
"""The `Graph` that contains this tensor."""
return self._op.graph
@property
def name(self):
"""The string name of this tensor."""
if not self._op.name:
raise ValueError("Operation was not named: %s" % self._op)
return "%s:%d" % (self._op.name, self._value_index)
@property
def device(self):
"""The name of the device on which this tensor will be produced, or None."""
return self._op.device
Tensor can be taken as target to run by session. Tensor contains all the information of Graph, and tracks data dependency.
Here is a detailed example:
>>> import tensorflow as tf
>>> c = tf.constant([[1.0, 2.0], [3.0, 4.0]])
>>> print c.graph
<tensorflow.python.framework.ops.Graph object at 0x10f256d50>
>>> d = tf.constant([[1.0, 1.0], [0.0, 1.0]])
>>> print d.graph
<tensorflow.python.framework.ops.Graph object at 0x10f256d50>
>>> e = tf.matmul(c, d)
>>> print e.graph
<tensorflow.python.framework.ops.Graph object at 0x10f256d50>
The core concept of symbolic API is Expression
, and Dynet defines Expression
class in C++.
A simple example is as follows:
ComputationGraph cg;
Expression W = parameter(cg, pW);
Expression in = input(cg, xs[i]);
Expression label = input(cg, ys[i]);
Expression pred = W * in;
Expression loss = square(pred - label);
The input data and parameter are also represented by Expression. Every basci Expression corresponds to a Node. And input data is also a Node.
Expression has a data member ComputationGraph, and ComputationGraph will be modified in users' configuring process. Expression can be a running target, beacuse Expression contains all dependency.
Here is a detailed example:
write topology in C++
ComputationGraph cg;
Expression W = parameter(cg, pW);
cg.print_graphviz();
Expression pred = W * xs[i];
cg.print_graphviz();
Expression loss = square(pred - ys[i]);
cg.print_graphviz();
compile and print
# first print
digraph G {
rankdir=LR;
nodesep=.05;
N0 [label="v0 = parameters({1}) @ 0x7ffe4de00110"];
}
# second print
digraph G {
rankdir=LR;
nodesep=.05;
N0 [label="v0 = parameters({1}) @ 0x7ffe4de00110"];
N1 [label="v1 = v0 * -0.98"];
N0 -> N1;
}
# third print
digraph G {
rankdir=LR;
nodesep=.05;
N0 [label="v0 = parameters({1}) @ 0x7ffe4de00110"];
N1 [label="v1 = v0 * -0.98"];
N0 -> N1;
N2 [label="v2 = -1.88387 - v1"];
N1 -> N2;
N3 [label="v3 = -v2"];
N2 -> N3;
N4 [label="v4 = square(v3)"];
N3 -> N4;
}
Actually, Symbol/Tensor/Expression in Mxnet/TensorFlow/Dynet are the same level concepts. We use a unified name Expression here, this level concept has following features:


Democracy.js Key Management
Accounts
Payout Recipient
Current Block Number
Metamask Detected
The following accounts and balances were detected.
Wallets Available


--- title: "How I learned to stop worrying and love the CDN" output: blogdown::html_page: toc: false toc_depth: 1 fig_width: 8 dev: "svg" author: "Houston Haynes" date: '2020-06-29T14:59:43+05:30' featuredpath: img featured: Azure-CDN.png ogfeatured: H3_og_wide_Azure-CDN.png description: Creating an HTTP rules bypass to invalidate cached assets at deploy time draft: false tags: - Azure - CDN - Verizon categories: - Sidebar weight: editor_options: chunk_output_type: inline ---
I love the concept of an R-blogdown based static web site - fast… simple… - OK, maybe just fast. There have been valid criticisms of static sites possessing an inherent “gateway drug” quality - a false sense of simplicity. But the idea really is to focus on the essential complexity of whatever you’re building, and skip past some of the incidental and accidental consequences of running the site on web server infrastructure.
But what happens when the platform/services your site depends on changes underneath your site? That happened to me, or at least I think it happened that way. This site has been in this form for more than a year, and I’ve been using the same deployment method for that time - and has never failed, until recently. A few weeks ago I cam back to post some updates, and the deployments kept failing. But before I get too deep in the weeds I suppose a bit of background is in order.
So when I returned to the site the behavior was oddly specific. Certain pages and assets were updating while others were remaining in the cache, even though I was refreshing at the top of the endpoint. And when I made API requests to invalidate specific pages and assets, they would continue to remain in the CDN. I toyed with the idea of setting a short TTL. But my reflex is to affirmatively set the state of the site during deploy, and check/test for it as part of a post-deploy process. The next step was to replicate all of my CDN settings to a new cache endoint, and it deployed cleanly! Horray! … only to be frustrated that on the NEXT deploy the same issue re-surfaced.
[cue sad trombone]
It took a considerable amount of investigation to finally come back to something in the CDN that was blocking the invalidation of certain assets in cache. The net effect was that new versions of certain site assets (such as my index page, of all things) would not update until the time-to-live had lapsed. This was incredibly frustrating, since it has been rock solid up to the point that the issue was discovered.
After some online spelunking I came to a discussion thread relating to a similar case, and the solution was to put a rule on top of each rule that essentially checked whether to skip processing. Basically if there was a purge request then skip the rule. This would in-effect put a bypass to the HTTP rules when a CDN cache invalidation request was coming in.
{{% fancybox-dark-theme-ok "/img" "CDN_purge_check.png" %}}
Honestly - in Verizon CDN parlance I’m not sure if it’s actually removing the files from the cache or simply marking them as invalid - but in either case, it works. Just be certain to put this IF statement at the top of every rule in the set you deploy.
So it goes to show that being “on the PaaS level” is not automatically the simpler approach. When breaking changes occur it’s often anguishing to trace back to the cause of the issue. That said, I’m not exactly sure how cache refreshes ever worked. For now I’ll set it aside and get back to working directly on this site, where my focus should actually reside.


External Websites:link1
Link into pages in the same directory:link1
Link into a nested directory:link1
link into pages into up one directory:link1
link into pages into up two directory:


| Modules | Description |
| Type extension | Description |
|
Extended Type:
|
|
Extended Type:
|
|
|
Extended Type:
|
|
Extended Type:
|
|
Extended Type:
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
Extended Type:
|
|
|
Extended Type:
|
|
|
Extended Type:
|
|
Extended Type:
|
|
|
Extended Type:
|
|
Extended Type:
|
|
|
Extended Type:
|
© Copyright 2021, DiffSharp Contributors.


class: center, middle, inverse, title-slide # Multinomial Logistic Regression and Batch Modeling with the Tidyverse ### Keith McNulty --- class: left, middle, r-logo ## Notes This document is coded in R. The code for this document is [here](https://github.com/keithmcnulty/peopleanalytics-regression-book/tree/master/presentations/multinom_tidymodels.Rmd). Python code for multinomial regression models can be found in the Appendix. --- class: left, middle, r-logo # Multinomial logistic regression for nominal category outcomes --- class: left, middle, r-logo ## Nominal category outcomes Nominal category outcomes are outcomes that can take the form of a number of categories or choices. These do not have any order to them. Examples of nominal category outcomes include: * Which candidate/political party was selected in an election? * Which product was selected from a choice of products? * Which career path did an employee end up in after 5 years? If there are only two choices, multinomial logistic regression equates to binomial logistic regression. If categories have an order (eg performance or survey ratings), they are known as ordinal categories. A multinomial approach also works for these, but there are better alternatives that are easier to interpret (eg proportional odds logistic regression). --- class: left, middle, r-logo ## The `health_insurance` data set This data set shows the choice made by a set of employees of one of three different company health insurance products, as well as various demographic and position data. ```r # get health insurance data set url <- "http://peopleanalytics-regression-book.org/data/health_insurance.csv" health_insurance <- read.csv(url) head(health_insurance) ``` ``` ## product age household position_level gender absent ## 1 C 57 2 2 Male 10 ## 2 A 21 7 2 Male 7 ## 3 C 66 7 2 Male 1 ## 4 A 36 4 2 Female 6 ## 5 A 23 0 2 Male 11 ## 6 A 31 5 1 Male 14 ``` We want to understand whether and how any of the other variables influence the choice of product. --- class: left, middle, r-logo ## One option is to use individual 'stratified' binomial models (1/2) We can create binary dummy variables for each product choice. ```r # create dummies for each product health_insurance_dummies <- dummies::dummy.data.frame(health_insurance, names = "product") head(health_insurance_dummies) ``` ``` ## productA productB productC age household position_level gender absent ## 1 0 0 1 57 2 2 Male 10 ## 2 1 0 0 21 7 2 Male 7 ## 3 0 0 1 66 7 2 Male 1 ## 4 1 0 0 36 4 2 Female 6 ## 5 1 0 0 23 0 2 Male 11 ## 6 1 0 0 31 5 1 Male 14 ``` --- class: left, middle, r-logo ## One option is to use individual 'stratified' binomial models (2/2) ```r # binomial on choice A modelA <- glm(productA ~ . - productB - productC, health_insurance_dummies, family = "binomial") summary(modelA) ``` ``` ## ## Call: ## glm(formula = productA ~ . - productB - productC, family = "binomial", ## data = health_insurance_dummies) ## ## Deviance Residuals: ## Min 1Q Median 3Q Max ## -2.19640 -0.43691 -0.07051 0.46304 2.37416 ## ## Coefficients: ## Estimate Std. Error z value Pr(>|z|) ## (Intercept) 5.873634 0.453041 12.965 < 2e-16 *** ## age -0.239814 0.013945 -17.197 < 2e-16 *** ## household 0.240205 0.037358 6.430 1.28e-10 *** ## position_level 0.321497 0.071770 4.480 7.48e-06 *** ## genderMale 0.845978 0.168237 5.028 4.94e-07 *** ## genderNon-binary 0.222521 1.246591 0.179 0.858 ## absent -0.003751 0.010753 -0.349 0.727 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## (Dispersion parameter for binomial family taken to be 1) ## ## Null deviance: 1864.15 on 1452 degrees of freedom ## Residual deviance: 940.92 on 1446 degrees of freedom ## AIC: 954.92 ## ## Number of Fisher Scoring iterations: 6 ``` --- class: left, middle, r-logo ## Multinomial regression approach Stratified approach has disadvantages: 1. Pretty laborious if there are lots of choices 2. Every model compares different categories - no common reference 3. Hard to simplify models or identify 'across the board' significance of variables Multinomial approach uses a common 'reference category' - let's say Product A - and models the odds of other choices relative to the reference: $$ \frac{P(y = B)}{P(y = A)} = \beta{X} \space , \space \frac{P(y = C)}{P(y = A)} = \gamma{X} $$ with different sets of coefficients `\(\beta\)` and `\(\gamma\)`. --- class: left, middle, r-logo ## Multinomial models using `nnet::multinom()` ```r multimodel<- nnet::multinom(product ~ ., health_insurance) summary(multimodel) ``` ``` ## Call: ## nnet::multinom(formula = product ~ ., data = health_insurance) ## ## Coefficients: ## (Intercept) age household position_level genderMale genderNon-binary ## B -4.60100 0.2436645 -0.9677237 -0.4153040 -2.38259765 0.2523409 ## C -10.22617 0.2698141 0.2043568 -0.2135843 0.09670752 -1.2715643 ## absent ## B 0.011676034 ## C 0.003263631 ## ## Std. Errors: ## (Intercept) age household position_level genderMale genderNon-binary ## B 0.5105532 0.01543139 0.06943089 0.08916739 0.2324262 1.226141 ## C 0.6197408 0.01567034 0.04960655 0.08226087 0.1954353 2.036273 ## absent ## B 0.01298141 ## C 0.01241814 ## ## Residual Deviance: 1489.365 ## AIC: 1517.365 ``` Output quite basic - just coefficients and standard errors. --- class: left, middle, r-logo ## Calculating p-values and odds ratios These need to be generated manually from the coefficients and standard errors: ```r # z-statistics (coefficients/standard errors) z_stats <- summary(multimodel)$coefficients/summary(multimodel)$standard.errors # p-values (p_values <- 2*(1-pnorm(abs(z_stats)))) ``` ``` ## (Intercept) age household position_level genderMale genderNon-binary ## B 0 0 0.000000e+00 3.199529e-06 0.0000000 0.8369465 ## C 0 0 3.796088e-05 9.419906e-03 0.6207192 0.5323278 ## absent ## B 0.3684170 ## C 0.7926958 ``` Similarly for odds ratio: ```r (odds_ratios <- exp(summary(multimodel)$coefficients)) ``` ``` ## (Intercept) age household position_level genderMale genderNon-binary ## B 1.004179e-02 1.275916 0.3799469 0.6601396 0.09231048 1.2870347 ## C 3.621021e-05 1.309721 1.2267357 0.8076841 1.10153815 0.2803927 ## absent ## B 1.011744 ## C 1.003269 ``` --- class: left, middle, r-logo ## Model simplification/elimination of variables * Start with the variable with the least significant p-values in all sets of coefficients---in our case `absent` would be the obvious first candidate * Run the multinomial model without this variable * Test that none of the previous coefficients change by more than 20-25% * If there was no such change, safely remove the variable and proceed to the next non-significant variable * If there is such a change, retain the variable and proceed to the next non-significant variable * Stop when all non-significant variables have been tested --- class: left, middle, r-logo # Batch modelling with the tidyverse --- class: left, middle, r-logo ## The `broom` package All the different modeling functions in R produce results in different formats, eg `lm()`, `glm()`, `nnet::multinom()`. This can make them challenging to perform manipulations on - as we saw in the `multinom()` output. The `broom` package is built to tidy up the outputs of models and render them as tidy tables so we can manipulate with tidyverse grammar. ```r # tidy approach to multinom (multimodel_tidy <- broom::tidy(multimodel)) ``` ``` ## # A tibble: 14 x 6 ## y.level term estimate std.error statistic p.value ## <chr> <chr> <dbl> <dbl> <dbl> <dbl> ## 1 B (Intercept) -4.60 0.511 -9.01 2.03e-19 ## 2 B age 0.244 0.0154 15.8 3.64e-56 ## 3 B household -0.968 0.0694 -13.9 3.73e-44 ## 4 B position_level -0.415 0.0892 -4.66 3.20e- 6 ## 5 B genderMale -2.38 0.232 -10.3 1.17e-24 ## 6 B genderNon-binary 0.252 1.23 0.206 8.37e- 1 ## 7 B absent 0.0117 0.0130 0.899 3.68e- 1 ## 8 C (Intercept) -10.2 0.620 -16.5 3.63e-61 ## 9 C age 0.270 0.0157 17.2 1.94e-66 ## 10 C household 0.204 0.0496 4.12 3.80e- 5 ## 11 C position_level -0.214 0.0823 -2.60 9.42e- 3 ## 12 C genderMale 0.0967 0.195 0.495 6.21e- 1 ## 13 C genderNon-binary -1.27 2.04 -0.624 5.32e- 1 ## 14 C absent 0.00326 0.0124 0.263 7.93e- 1 ``` --- class: left, middle, r-logo ## We can now manipulate using tidyverse grammar ```r # add odds ratio easily using `dplyr` multimodel_tidy %>% dplyr::mutate(odds_ratio = exp(estimate)) ``` ``` ## # A tibble: 14 x 7 ## y.level term estimate std.error statistic p.value odds_ratio ## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 B (Intercept) -4.60 0.511 -9.01 2.03e-19 0.0100 ## 2 B age 0.244 0.0154 15.8 3.64e-56 1.28 ## 3 B household -0.968 0.0694 -13.9 3.73e-44 0.380 ## 4 B position_level -0.415 0.0892 -4.66 3.20e- 6 0.660 ## 5 B genderMale -2.38 0.232 -10.3 1.17e-24 0.0923 ## 6 B genderNon-binary 0.252 1.23 0.206 8.37e- 1 1.29 ## 7 B absent 0.0117 0.0130 0.899 3.68e- 1 1.01 ## 8 C (Intercept) -10.2 0.620 -16.5 3.63e-61 0.0000362 ## 9 C age 0.270 0.0157 17.2 1.94e-66 1.31 ## 10 C household 0.204 0.0496 4.12 3.80e- 5 1.23 ## 11 C position_level -0.214 0.0823 -2.60 9.42e- 3 0.808 ## 12 C genderMale 0.0967 0.195 0.495 6.21e- 1 1.10 ## 13 C genderNon-binary -1.27 2.04 -0.624 5.32e- 1 0.280 ## 14 C absent 0.00326 0.0124 0.263 7.93e- 1 1.00 ``` --- class: left, middle, r-logo ## The `glance()` function is useful for model statistics ```r model <- lm(mpg ~ hp + wt + disp + carb, mtcars) broom::glance(model) ``` ``` ## # A tibble: 1 x 12 ## r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC ## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 0.828 0.802 2.68 32.4 6.02e-10 4 -74.3 161. 169. ## # … with 3 more variables: deviance <dbl>, df.residual <int>, nobs <int> ``` This allows the batch running and assessing of models on subsets of data. ```r mtcars %>% dplyr::nest_by(cyl) %>% dplyr::summarise( lm(mpg ~ hp + wt + disp + carb, data) %>% broom::glance() ) ``` ``` ## # A tibble: 3 x 13 ## # Groups: cyl [3] ## cyl r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC ## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 4 0.743 0.572 2.95 4.35 0.0546 4 -24.2 60.3 62.7 ## 2 6 0.896 0.688 0.812 4.31 0.197 4 -4.09 20.2 19.8 ## 3 8 0.533 0.326 2.10 2.57 0.110 4 -27.2 66.3 70.2 ## # … with 3 more variables: deviance <dbl>, df.residual <int>, nobs <int> ``` --- class: left, middle, r-logo ## This also allows different variable combinations to be run and assessed ```r # create dataframe with a column of model formulas models <- data.frame( formula = c( "mpg ~ cyl", "mpg ~ cyl + wt", "mpg ~ cyl + wt + carb", "mpg ~ cyl + wt + carb + hp", "mpg ~ cyl + wt + carb + hp + disp" ) ) # run all models models %>% dplyr::rowwise() %>% dplyr::mutate( lm(formula, mtcars) %>% broom::glance() ) ``` ``` ## # A tibble: 5 x 13 ## # Rowwise: ## formula r.squared adj.r.squared sigma statistic p.value df logLik AIC ## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 mpg ~ … 0.726 0.717 3.21 79.6 6.11e-10 1 -81.7 169. ## 2 mpg ~ … 0.830 0.819 2.57 70.9 6.81e-12 2 -74.0 156. ## 3 mpg ~ … 0.842 0.826 2.52 49.9 2.32e-11 3 -72.8 156. ## 4 mpg ~ … 0.845 0.822 2.54 36.9 1.41e-10 4 -72.5 157. ## 5 mpg ~ … 0.849 0.820 2.56 29.2 7.06e-10 5 -72.2 158. ## # … with 4 more variables: BIC <dbl>, deviance <dbl>, df.residual <int>, ## # nobs <int> ``` --- class: left, middle, r-logo ## Appendix - Multinomial logistic regression code in Python ```python import pandas as pd import statsmodels.api as sm # load health insurance data url = "http://peopleanalytics-regression-book.org/data/health_insurance.csv" health_insurance = pd.read_csv(url) # convert product to categorical as an outcome variable y = pd.Categorical(health_insurance['product']) # create dummies for gender X1 = pd.get_dummies(health_insurance['gender'], drop_first = True) # replace back into input variables X2 = health_insurance.drop(['product', 'gender'], axis = 1) X = pd.concat([X1, X2], axis = 1) # add a constant term to ensure intercept is calculated Xc = sm.add_constant(X) # define model model = sm.MNLogit(y, Xc) # fit model insurance_model = model.fit() ``` ``` ## Optimization terminated successfully. ## Current function value: 0.512514 ## Iterations 8 ``` --- class: left, middle, r-logo ## Appendix - Multinomial logistic regression results in Python ```python print(insurance_model.summary()) ``` ``` ## MNLogit Regression Results ## ============================================================================== ## Dep. Variable: y No. Observations: 1453 ## Model: MNLogit Df Residuals: 1439 ## Method: MLE Df Model: 12 ## Date: Tue, 02 Mar 2021 Pseudo R-squ.: 0.5332 ## Time: 16:34:40 Log-Likelihood: -744.68 ## converged: True LL-Null: -1595.3 ## Covariance Type: nonrobust LLR p-value: 0.000 ## ================================================================================== ## y=B coef std err z P>|z| [0.025 0.975] ## ---------------------------------------------------------------------------------- ## const -4.6010 0.511 -9.012 0.000 -5.602 -3.600 ## Male -2.3826 0.232 -10.251 0.000 -2.838 -1.927 ## Non-binary 0.2528 1.226 0.206 0.837 -2.151 2.656 ## age 0.2437 0.015 15.790 0.000 0.213 0.274 ## household -0.9677 0.069 -13.938 0.000 -1.104 -0.832 ## position_level -0.4153 0.089 -4.658 0.000 -0.590 -0.241 ## absent 0.0117 0.013 0.900 0.368 -0.014 0.037 ## ---------------------------------------------------------------------------------- ## y=C coef std err z P>|z| [0.025 0.975] ## ---------------------------------------------------------------------------------- ## const -10.2261 0.620 -16.501 0.000 -11.441 -9.011 ## Male 0.0967 0.195 0.495 0.621 -0.286 0.480 ## Non-binary -1.2698 2.036 -0.624 0.533 -5.261 2.721 ## age 0.2698 0.016 17.218 0.000 0.239 0.301 ## household 0.2043 0.050 4.119 0.000 0.107 0.302 ## position_level -0.2136 0.082 -2.597 0.009 -0.375 -0.052 ## absent 0.0033 0.012 0.263 0.793 -0.021 0.028 ## ================================================================================== ```


full color OS
+
Stereo OS
GAME, YES, GAME!
Amiga 4.01
Mac?
Windows?
Linux?
Amiga?
Media archaeology, kinda
ps:put S button on the keyboard to view the notes
Undead?
ps:put S button on the keyboard to view the notes
ps:put S button on the keyboard to view the notes
Another one
ps:put S button on the keyboard to view the notes
the END
ps:put S button on the keyboard to view the notes


--- title: Five Firms Hold 80% of Derivatives Risk layout: post ---
About 80% of the derivative assets and liabilities carried on the balance sheets of 100 companies reviewed by Fitch were held by five banks: JP Morgan Chase, Bank of America, Goldman Sachs, Citigroup, and Morgan Stanley. Those five banks also account for more than 96% of the companies' exposure to credit derivatives.
You're telling me that they found a power law governing the distribution of something created by the independent actions of human beings? I'm shocked...


Design for Music Iterated Learning
JAIST Information Science D2
JSPS Young Fellow DC1
Hiroki Sudo
Nov. 10, 2018
Model
Procedure
- Explain a purpose of our research and the procedure to participants
- Let participants play the application to get used to it
- Give a chance to ask questions about the application
- Make a pair in participants, which is one teacher and one learner
Procedure
- Give a each pair a generation number
- Give 10 times of communication on the generation(One step is that a learner imitates parent's music and they switch roles.)
- Give a record of communication next generation
Meaning Space
- A whole scores, 300 kinds
- The iteration constructs new meaning by human feeling and bias.
- A learner must guess a meaning of a teacher's to imitate it because the learner could not always choise scores the teacher selected.
Learning Bottleneck
- A half of scores, 150 kinds
- When a teacher and a learner make music, they are given 150 scores which is selected randomly.
- The learner would not construct the same music as the teacher's one.
Learning(Modification)
- 9 times on the generation and record of a previous generation
- A teacher could guess the learner's cognition what he/she focused on from the imitation.
- Participants could refer the previous record, when making and imitating music.
Hypothesis
- Pitch structure(similar keys, similar pitches and so on)?
- Melodic pattern structure(a form based on difference between pitches)?
- Is it explained by music theory?


#assign n0_docs="true"> <#assign n1_query_find="true"> <#assign findStream="true">
Execute the query processing the result as a stream. Use a try with resources
block
to ensure the resources held by the stream are closed.
Note that this will use a single persistence context and all beans streamed will
be held in that persistence context so this isn't appropriate (will require too much
memory) when streaming a huge result set and findLargeStream()
should be used
instead for that case.
findStream()
does a similar job to findEach
and
findIterate
with the difference largely down to style.
findLargeStream()
is similar to findStream()
except it will use
multiple persistence contexts. This means it can process huge result sets.


--- layout: post title: First Day of the New Year author: josh tags: - family - holiday - new year ---
So today was the beginning of the New Year, 2010, and I have to say, I rather enjoyed the day off and the time with my family.
Today, I slept in and was awoken by my wife telling me that breakfast was ready at a very early 11am. After breakfast and beginning to get ready for our day, I realized it wasn't Saturday yet, and I get another whole day like this.
We made our way to the mall to buy me some new jeans (I was in desperate need of some, as the ones I had been wearing were wearing quite thin).  I really love getting to spend time with my "buddy".
After that, it was "mom and dad" time. We took advantage of that by spending a little time on the computers before having our favorite movie night dinner - chicken fingers. Yum!
I'm finally heading off to bed... and well, I get to do a day like this all over again tomorrow. I love my family.


Creating a subscription and subsequent billing periods generates invoices.
No customers have been generated yet.