docstr: Tests that LSM price of European put option is computed as expected.
docstr_tok: ["Tests","that","LSM","price","of","European","put","option","is","computed","as","expected","."]
code: def test_european_option_put(self, dtype):
      """Tests that LSM price of European put option is computed as expected."""
      # This is the same example as in Section 1 of
      # Longstaff, F.A. and Schwartz, E.S., 2001. Valuing American options by
      # simulation: a simple least-squares approach. The review of financial
      # studies, 14(1), pp.113-147.
      basis_fn = lsm_algorithm.make_polynomial_basis(2)
      payoff_fn = lsm_algorithm.make_basket_put_payoff(
          [1.1], dtype=dtype
      )
      # Option price
      european_put_price = lsm_algorithm.least_square_mc(
          self.samples,
          [3],
          payoff_fn,
          basis_fn,
          discount_factors=[self.discount_factors[-1]],
          dtype=dtype,
      )
      self.assertAllClose(
          european_put_price, [0.0564], rtol=1e-4, atol=1e-4
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/longstaff_schwartz/lsm_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 2 for calling the LsmTest obj's underlying member method code with example usage: obj.test_european_option_put(dtype) without return types