std

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

std

Octave - General mailing list
hi, look that:


>> vv=media(20:40)
vv =

    433.59
    485.94
    590.62
    632.81
    674.22
    714.45
    769.14
    839.06
    934.77
    932.42
    998.05
   1058.59
   1069.92
   1005.08
    923.44
    835.16
    727.34
    618.36
    471.88
    360.94
    269.53

i want to do std in 5 element:

> std(vv,0,5)
ans =

   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0


Why i get this result? All zero




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: std

Octave - General mailing list
On 5/17/19 2:41 PM, turbofib via Help-octave wrote:
i want to do std in 5 element:

std(vv,0,5)
ans =

   0
   0
   0

'help std' explains that the third argument to std() specifices the dimension along which you take the std(). Your data has just one dimension, so the result is zero.

What do you want to calculate? what  do you mean by 'std in 5 element'?



Reply | Threaded
Open this post in threaded view
|

Re: std

Octave - General mailing list
hi,
sorry but i don't understand..

look this example:

1
2
3
4
8 2,701851217 (stdev 5 last element)
6 2,408318916 (stdev 5 last element)
7 2,073644135 (stdev 5 last element)
8 1,673320053 (stdev 5 last element)
9 1,140175425 (stdev 5 last element)
10 1,58113883 (stdev 5 last element)

this is result using excel..

(is not zero as octave give me :)


 



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: std

Mike Miller-4
On Fri, May 17, 2019 at 17:11:21 -0500, turbofib via Help-octave wrote:

> hi,
> sorry but i don't understand..
>
> look this example:
>
> 1
> 2
> 3
> 4
> 8 2,701851217 (stdev 5 last element)
> 6 2,408318916 (stdev 5 last element)
> 7 2,073644135 (stdev 5 last element)
> 8 1,673320053 (stdev 5 last element)
> 9 1,140175425 (stdev 5 last element)
> 10 1,58113883 (stdev 5 last element)
>
> this is result using excel..
>
> (is not zero as octave give me :)
You are looking for the moving standard deviation, calculated over a
sliding window.

    >> lookfor "standard deviation"
    movstd              Calculate the moving standard deviation over a s...
    statistics          Return a vector with the minimum, first quartile...
    std                 Compute the standard deviation of the elements o...
    >> movstd (x, 5)
    >> movstd (x, [4, 0])

--
mike



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: std

Juan Pablo Carbajal-2
In reply to this post by Octave - General mailing list
Hi,

You need to get use to read the help of the functions. The third input
argument of std indicates along which dimension the function will
compute, that is 1 for "along columns", 2 for "along rows", 3 for
"along pages" (in a 3D matrix), etc...

We do not understand what you want to do with. If you explain what you
mean by "5 elements" we can give better answers.

From you example it seems you mean the std in the last 5 elements, that would be

std (vv(end-4:end))
ans =  186.01

If you want std on a moving window of size 5 you can do

movstd(data, 5)
ans =

    79.955
    91.922
   100.859
    87.834
    69.483
    80.843
   103.496
    97.835
    90.237
    82.031
    65.459
    54.994
    58.322
    98.814
   135.773
   153.632
   177.823
   190.644
   186.009
   150.281
   101.332


Reply | Threaded
Open this post in threaded view
|

Re: std

Juan Pablo Carbajal-2
Your excel example would be

movstd([1:4 8 6 7:10].',[4 0])
ans =

   0.00000
   0.70711
   1.00000
   1.29099
   2.70185
   2.40832
   2.07364
   1.67332
   1.14018
   1.58114


Reply | Threaded
Open this post in threaded view
|

Re: std

Octave - General mailing list
thank you for answer..

I need it because i want to use bollinger band

I tryed to use bolling (function of package financial octave) but the result
is  different from Excel Calculation

so I decided to calculate it by hand

Upper Band =Period-day SMA + (Period-day standard deviation of price x 2)
Lower Band = Period-day SMA – (Period-day standard deviation of price x 2)



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: std

Octave - General mailing list
In reply to this post by Mike Miller-4