graph icon indicating copy to clipboard operation
graph copied to clipboard

No such property: mean for class: groovysh_evaluate

Open PavelVBushmakin opened this issue 5 years ago • 2 comments

g.withSideEffect("m",mean).withSideEffect("c",count).V().hasLabel('airport').values('runways').math('(_ - m)^2').sum().math('_ / c').math('sqrt(_)')

No such property: mean for class: groovysh_evaluate
Type ':help' or ':h' for help.
Display stack trace? [yN]

3.29.6. Calculating a standard deviation

PavelVBushmakin avatar Mar 09 '20 23:03 PavelVBushmakin

It is calculated in the example two above above in the same chapter

mean=g.V().hasLabel('airport').values('runways').mean().next()

1.4309425014819206

krlawrence avatar Mar 09 '20 23:03 krlawrence

I should probably add an example that does the whole thing in one query.

gremlin> g.V().hasLabel('airport').
......1>       values('runways').fold().as('runways').
......2>       mean(local).as('mean').
......3>       select('runways').unfold().
......4>       math('(_-mean)^2').mean().math('sqrt(_)') 
==>0.7510927827902234
gremlin>

krlawrence avatar Mar 09 '20 23:03 krlawrence

Closing as this is fixed and work has now started on the second edition. There will likely be one final release of the v283 first edition line before the V2 branch becomes the second edition. That release will include these fixes.

krlawrence avatar Sep 23 '23 18:09 krlawrence