# Translate Code?

Roger Guay irog at mac.com
Thu Dec 3 21:15:54 EST 2020

```Thank you, Alex. This gives me something to play with.

Roger

> On Dec 3, 2020, at 3:45 PM, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> I'll have a try - though it's in R, not Python - and I've never used R -)
>
> constant alpha = 2
> constant n = 1000
> -- x, y are arrays - initialised to 0 already for LC, so no need for "rep"
>
> repeat with i = 2 to n
>   -- runif(1) returns a random between 0 and 1, so do something similar
>   put (random(10000) / 10000) * 2 * pi into theta
>   put (random(10000) / 10000) ^ (-1/alpha) into f
>   put x[i-1] + f*cos(theta) into x[i]
>   put y[i-1] + f * sin(theta) into y[i]
> end repeat
>
> Any mistakes are mine - any correct bits are courtesy of Google -)
>
> -- Alex.
>
> On 03/12/2020 19:48, Roger Guay via use-livecode wrote:
>> Can someone please translate the code below into LC ? I believe it to be Python?
>> alpha=2
>> n=1000
>> x=rep(0,n)
>> y=rep(0,n)
>>
>> for (i in 2:n){
>>    theta=runif(1)*2*pi
>>    f=runif(1)^(-1/alpha)
>>    x[i]=x[i-1]+f*cos(theta)
>>    y[i]=y[i-1]+f*sin(theta)
>> }
>>
>> Thanks very much,
>>
>> Roger
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

```