tanh_ramp_stf

signals.tanh_ramp_stf(center_time, ramp_duration, end_value, start_value=None)

Create an Stf representing a hyperbolic tangent ramp.

Parameters

  • center_time (float or Tensor) – The time at which the ramp has its greatest slope, t0t_0
  • ramp_duration (float or Tensor) – The characteristic time for the hyperbolic tangent ramp, trampt_\mathrm{ramp}
  • end_value (float or complex or Tensor) – The asymptotic value of the ramp towards t+t \to +\infty, a+a_+
  • start_value (float or complex or Tensor , optional) – The asymptotic value of the ramp towards tt \to -\infty, aa_-

Returns

The sampleable hyperbolic tangent ramp.

Return type

Stf

SEE ALSO

Graph.signals.linear_ramp_stf : Create an Stf representing a linear ramp.

boulderopal.signals.tanh_ramp : Create a Signal object representing a hyperbolic tangent ramp.

Graph.signals.tanh_ramp_pwc : Corresponding operation with Pwc output.

Graph.tanh : Calculate the element-wise hyperbolic tangent of an object.

Notes

The hyperbolic tangent ramp is defined as

Tanh(t)=a++a2+a+a2tanh(tt0tramp), \mathop{\mathrm{Tanh}}(t) = \frac{a_+ + a_-}{2} + \frac{a_+ - a_-}{2} \tanh\left( \frac{t - t_0}{t_\mathrm{ramp}} \right) ,

where the function’s asymptotic values a±a_\pm

a±:=limt±Tanh(t), a_\pm := \lim_{t\to\pm\infty} \mathop{\mathrm{Tanh}}(t) ,

and t0t_0 is related to trampt_\mathrm{ramp}

dTanh(t)dtt=t0=(a+a)2tramp. \left.\frac{{\rm d}\mathop{\mathrm{Tanh}}(t)}{{\rm d}t}\right|_{t=t_0} = \frac{ (a_+ - a_-)}{2 t_\mathrm{ramp}} .

With the default value of start_value (aa_-

Tanh(t)=Atanh(tt0tramp), \mathop{\mathrm{Tanh}}(t) = A \tanh\left( \frac{t - t_0}{t_\mathrm{ramp}} \right) ,

where A=a+A = a_+ is the end value (the start value is then A-A

Examples

Define a simple sampleable hyperbolic tangent ramp.

>>> tanh = graph.signals.tanh_ramp_stf(
...     center_time=0.4, ramp_duration=0.2, end_value=2, start_value=-1
... )
>>> graph.discretize_stf(tanh, duration=1, segment_count=5, name="tanh")
<Pwc: name="tanh", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = bo.execute_graph(graph=graph, output_node_names="tanh")
>>> result["output"]["tanh"]
{'durations': array([0.2, 0.2, 0.2, 0.2, 0.2]),
'values': array([-0.85772238, -0.19317574,  1.19317574,  1.85772238,  1.97992145]),
'time_dimension': 0}

Define a hyperbolic tangent ramp with optimizable parameters.

>>> center_time = graph.optimizable_scalar(
...     lower_bound=0.25e-6, upper_bound=0.75e-6, name="center_time"
... )
>>> ramp_duration = graph.optimizable_scalar(
...     lower_bound=0.1e-6, upper_bound=0.3e-6, name="ramp_duration"
... )
>>> end_value = graph.optimizable_scalar(
...     lower_bound=0, upper_bound=3e6, name="end_value"
... )
>>> graph.signals.tanh_ramp_stf(
...     center_time=center_time, ramp_duration=ramp_duration, end_value=end_value
... )
<Stf: operation_name="add", value_shape=(), batch_shape=()>

Was this useful?