Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I define function which return a list of numbers

KSmoothTest[vy_, b_] := Block[{n, res, i, j, weights},
   n = Length[vy];
   weights = Table[K[i/b], {i, 0, Length[vy] - 1}];
   Table[Sum[weights[[Abs[i - j] + 1]]*vy[[j]], {j, 1, n}]/
     Sum[weights[[Abs[i - j] + 1]], {j, 1, n}], {i, 1, n}]
   ];

I want run this code

Table[ListLinePlot[KSmoothTest[RandomReal[{-10, 10}, 10], 9]], {i, 1, 10}]

in parallel using ParallelTable. I try this

ParallelTable[ListLinePlot[KSmoothTest[RandomReal[{-10, 10}, 10], 9]], {i, 1, 10}]

but Mathematica return graphics like this:

What is wrong? Why Mathematica return empty graphic? PS: sory for my english, i am not strong in it

EDIT: K[t_]:=1.078222*Exp[-(t^2/0.273800)];

share|improve this question
    
Two questions:- What is K? and why are you using Block (Rather than Module)? –  Ymareth May 6 at 14:34
1  
K is a default generic name for a summation index in a symbolic sum. I'm not sure you mean that :) –  Öskå May 6 at 14:35
    
oh, fogot for this funtion. Please read now –  molekyla777 May 6 at 14:37
    
really? I don't see definition of this symbol in documentation centre –  molekyla777 May 6 at 14:40
    
?K returns what I wrote above. And it's in black, so it's built-in :) –  Öskå May 6 at 14:42

1 Answer 1

up vote 1 down vote accepted

The problem is that you are using a built-in symbol K in your KSmoothTest function. K appears black and

?K

returns

K is a default generic name for a summation index in a symbolic sum.

Thus by turning K into k you have:

k[t_] := 1.078222*Exp[-(t^2/0.273800)];
KSmoothTest[vy_, b_] := Block[{n, weights}, n = Length[vy];
  weights = Table[k[i/b], {i, 0, Length[vy] - 1}];
  Table[Sum[weights[[Abs[i - j] + 1]]*vy[[j]], {j, 1, n}]/
    Sum[weights[[Abs[i - j] + 1]], {j, 1, n}], {i, 1, n}]];

ParallelTable[ ListLinePlot[KSmoothTest[RandomReal[{-10, 10}, 10], 9]], {j, 1, 2}]

enter image description here

share|improve this answer
1  
One question remains.., why does it work with Table and not ParellelTable. –  Öskå May 6 at 14:50
    
Thank for help. I made bad mistake) –  molekyla777 May 6 at 14:50
    
@molekyla777 We all did :) –  Öskå May 6 at 14:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.