krlawrence / graph

Practical Gremlin - An Apache TinkerPop Tutorial
Apache License 2.0
836 stars 253 forks source link

No such property: mean for class: groovysh_evaluate #174

Closed PavelVBushmakin closed 1 year ago

PavelVBushmakin commented 4 years ago
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

krlawrence commented 4 years ago

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 commented 4 years ago

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 commented 1 year ago

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.