import scipy as sp
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
priceX = [52., 86.4, 22.5, 134]; shareX = [500, 250, 400, 300]
priceX
np.dot(priceX, shareX)
Note: this will not be the same as the Mathematica example in .nb file because of random data
matp2=np.floor((2*(9*np.random.rand(4,2)+15)+0.5))/2.
matp2
nmat2 = [[63.5, 71.5, 50], [117.25, 143.5, 91]]
wkcost=np.dot(matp2,nmat2)
wkcost
ingrmat = [[0., 0.3, 0.1, 0.5, 0.4]
, [0.75, 0.25, 0.5, 0.2, 0.6]];
prodmat = [[55, 70, 40]
, [80, 50, 40]
, [30, 45, 30]
, [25, 40, 30]
, [60, 80, 50]];
demandmat=np.dot(ingrmat,prodmat)
demandmat
random price here is not the same as the Mathematica tutorial example
wkcost=np.dot(matp2,demandmat);
print(wkcost)
result1=np.dot(matp2,np.dot(ingrmat,prodmat))
result2=np.dot(np.dot(matp2,ingrmat),prodmat)
print(result1)
print(result2)
mdim=5; ndim=3 ; pdim=4 ; rint=10;
matA=np.floor((np.random.rand(mdim,ndim)-0.5)*2*rint+0.5)
matAT=np.transpose(matA)
matB=np.floor((np.random.rand(ndim,pdim)-0.5)*2*rint+0.5)
matBT=np.transpose(matB)
print(np.transpose(np.dot(matA,matB)))
print(np.dot(matBT,matAT))
from scipy import linalg
purchM=[[4, 2, 4], [3, 3, 9], [9, 0, 3]]
total=[10.6, 17.1, 11.4]
price=linalg.solve(purchM,total)
print(price)
purchInv=linalg.inv(purchM)
print(purchInv)
np.dot(purchInv,total)