1

I would like to compute the following expression in Wolfram alpha: $$\mathbb{E}[X-max(aX+b,0)] $$ where $X\sim N(\mu,\sigma^2)$ and $a,b$ are some constants.

Without constants, I can get the result with

expectation of (x-max(x,0)), x normal distributed

However, the following doesn't seem to work:

expectation of (x-max(ax+b,0)), x normal distributed

Do you know how I can get the general result with some arbitrary constants ?

Thanks in advance !

Wiles01
  • 123
  • 5
  • 5
    I’m voting to close this question because questions on Wolfram Alpha is considered off-topic in this site: https://mathematica.stackexchange.com/help/on-topic – xzczd Aug 09 '22 at 15:08

1 Answers1

5

I think your problem is "aX". This is interpreted as one variable name. You need a space between names. Then the following works:

Clear["Global`*"]
Expectation[x - Max[a x - b,0], x \[Distributed] NormalDistribution[mu, sig]]

enter image description here

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
  • Thanks a lot for your answer ! I am quite new and I tried this on Wolfram Alpha: https://www.wolframalpha.com/input?i=Clear%5B%22Global%60*%22%5D+Expectation%5Bx+-+Max%5Ba+x+-+b%5D%2C+x+%5C%5BDistributed%5D+NormalDistribution%5Bmu%2C+sig%5D%5D but it doesn't seem to work. Do I need to use the paid version ? – Wiles01 Aug 05 '22 at 10:06
  • 1
    Thanks for your response ! To compute this expression, I need Mathematica ? The online free Wolfram Alpha is not enough ? – Wiles01 Aug 05 '22 at 10:23
  • 1
    I tried it on WolframAlpha, but it seems that WolframAlpha does not know about "Expectation" – Daniel Huber Aug 05 '22 at 13:19
  • Thanks. I will install the trial version of Mathematica then... – Wiles01 Aug 05 '22 at 13:38
  • I think you forgot the zero in the Max function: Expectation[x - Max[0, a x + b], x \[Distributed] NormalDistribution[\[Mu], \[Sigma]]]. – JimB Aug 05 '22 at 14:56
  • You are right, thank you. – Daniel Huber Aug 05 '22 at 15:05
  • 1
    @Wiles01 You can install the full version for free and use Jupiter notebook interface https://mathematica.stackexchange.com/questions/198839/how-to-add-a-front-end-to-the-free-wolfram-engine. – yarchik Aug 05 '22 at 15:21
  • Thanks ! What does "True" mean in the last case of the output ? – Wiles01 Aug 05 '22 at 16:09
  • 1
    True means: all other cases – Daniel Huber Aug 05 '22 at 16:10
  • 1
    You can get a simpler result if you simplify using the constraints on mu and sig required for the distribution to be valid, i.e., mu \[Element] Reals && sig > 0 – Bob Hanlon Aug 05 '22 at 16:43
  • Thanks, I will try that simplification. – Wiles01 Aug 05 '22 at 16:50