SHOW:
|
|
- or go back to the newest paste.
1 | - | from __future__ import print_function |
1 | + | stc = function(data, n) { |
2 | for(var i=0; i < data.length; i++) { | |
3 | - | def stc(data, n): |
3 | + | data[i] *= Math.pow((i+1) / data.length, 1 / n); |
4 | - | ret = [] |
4 | + | } |
5 | - | for i in range(len(data)): |
5 | + | return data |
6 | - | result = pow((i+1) / len(data), 1 / n) |
6 | + | } |
7 | - | ret.append(result) |
7 | + | |
8 | - | return ret |
8 | + | |
9 | > stc([0,1,2,3,4,5,6,7,8,9,10], 2) | |
10 | - | print(stc([1]*10, 2)) |
10 | + | [ 0, |
11 | 0.4264014327112209, | |
12 | 1.044465935734187, | |
13 | 1.8090680674665818, | |
14 | 2.696799449852968, | |
15 | 3.692744729379982, | |
16 | 4.786344211304794, | |
17 | - | [0.31622776601683794, |
17 | + | 5.969620057957092, |
18 | - | 0.4472135954999579, |
18 | + | 7.236272269866327, |
19 | - | 0.5477225575051661, |
19 | + | 8.581163303210332, |
20 | - | 0.6324555320336759, |
20 | + | 10 ] |
21 | - | 0.7071067811865476, |
21 | + | > |