0

I am trying to use a matrix to approximate another.

I have a 1000x96 matrix called Bpp and I need to create a new matrix, Omega, from it, in this form:

Approx of Matrix

where b′′(z_i)_l is the i,l entry of Bpp (Bpp is a 1000x96 matrix)

I have this attempt:

Omega = matrix(0, 96, 96)

for(k in 1:96){
   for(l in 1:96){
     Omega[k,l] = sum(Bpp[,k]*Bpp[,l]*delta)
   }
}

But I'm almost certain it isn't right, as it's not producing the results I need in a later problem.

Thanks in advance for help/guidance.

Parfait
  • 104,375
  • 17
  • 94
  • 125
Miguel
  • 5
  • 2
  • In the link above, what do those values stand for ? Better, if you can explain the equation in simple english. Without knowing exactly, hard to form a solution. Surely, you don't need loops for this, you can do matrix multiplication, much faster option. – YOLO Dec 02 '18 at 22:42
  • @YOLO n the link, each b is the i,k/l entry of the Bpp matrix with the above dimensions. So for example, b''(z_2)_3 would be the entry in the second row and third column of Bpp. Does that clarify it? – Miguel Dec 02 '18 at 22:46
  • okay, and what is the value for delta ? – YOLO Dec 02 '18 at 23:08
  • it's a constant, in this case, it ends up being 0.01616617 – Miguel Dec 02 '18 at 23:18
  • *It's not producing the results*... not producing *any* results or incorrect results? Please set up a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with a smaller matrix *Bpp* maybe `4x4` and then show desired *Omega*. `dput(Bpp[4,4])` is one way. To be clear, show us input data and desired output. – Parfait Dec 02 '18 at 23:49

1 Answers1

0

I think you want to do the inner product. It will multiply and sum each column of Bpp and all its 96 columns, the same thing your loop does.

Omega = t(Bpp)*Bpp*delta
YOLO
  • 20,181
  • 5
  • 20
  • 40