nest-simulator icon indicating copy to clipboard operation
nest-simulator copied to clipboard

No clipping for random parameters in nest 3.2

Open morales-gregorio opened this issue 2 years ago • 3 comments

Hi,

with the new Parameter objects there seems to be no support anymore for clipped distributions. This is particularly problematic for the case of delays, since the smallest delay should be set to the same size as the resolution of the simulation.

The documentation seems to indicate that this is possible (this exact functionality is what I would like to use),

# CreateParameter(parametertype, specs)

# random parameter with uniform distribution in [min,max)
'uniform' :
    {'min' : float, # minimum value, default: 0.0
     'max' : float} # maximum value, default: 1.0

# random parameter with normal distribution, optionally truncated
# to [min,max)
'normal':
    {'mean' : float, # mean value, default: 0.0
     'sigma': float, # standard deviation, default: 1.0
     'min'  : float, # minimum value, default: -inf
     'max'  : float} # maximum value, default: +inf

# random parameter with lognormal distribution,
# optionally truncated to [min,max)
'lognormal' :
    {'mu'   : float, # mean value of logarithm, default: 0.0
     'sigma': float, # standard deviation of log, default: 1.0
     'min'  : float, # minimum value, default: -inf
     'max'  : float} # maximum value, default: +inf

but the actual implementation (nest/random/hl_api_random.py) not only does not have the min/max keywords but also it uses different keywords altogether.

This feature seems to have existed before and is in my opinion a serious drawback of Nest 3.x in comparison to the old 2.x way of doing things. Can someone have a look and bring it back?

Thanks, Aitor

morales-gregorio avatar Mar 22 '22 16:03 morales-gregorio

That piece of documentation looks outdated and should be fixed.

You can still clip a distribution, but it is no longer baked into the random parameter. You can use nest.math.min() with a Parameter object and a value as arguments, and the result will be the smaller of the two. This is similar to clipping the high end of a distribution to a given value. Likewise you can use nest.math.max() and clip the low end of the distribution. You may also use nest.math.redraw(), which takes both high and low limits and redraws the value if it lays outside of the given limits (the limits support numpy.Inf). See the documentation for more details.

hakonsbm avatar Mar 24 '22 15:03 hakonsbm

Hi! Thanks for the tip, it would be great to see this somehow built into the docs. Works perfectly fine now :)

It seems to also be relevant that when using nest.math.min(Parameter, float) the order of the inputs is kept, I am fine with this although I guess it should be explicitly said in the docs since it is not so intuitive that this should matter.

Best, Aitor

morales-gregorio avatar Apr 12 '22 15:04 morales-gregorio

Issue automatically marked stale!

github-actions[bot] avatar Jun 12 '22 08:06 github-actions[bot]

@hakonsbm Could you update the documentation?

heplesser avatar Nov 25 '22 15:11 heplesser