title: Simulate left Truncated Gamma distribution with mean = 1 and variance =0.4
body: <p>Suppose X~&Gamma;(&alpha;, &beta;), I would like to truncate all values of X
  
  <p>MATLAB codes:</p>
  
  <pre><code>t = 0.5;  theta = 0.4; 
  syms alpha beta 
  EX = beta*( igamma(alpha+1,t/beta) /  igamma(alpha,t/beta) ); %Mean  
  EX2 = beta^2*( igamma(alpha+2,t/beta) /  igamma(alpha,t/beta) );%Second moment         
  VarX = EX2 -EX^2; %Variance       
  cond1 = alpha &gt; 0; cond2 = beta &gt; 0; cond3 = EX==1; cond4 = VarX ==theta;
  conds =[cond1 cond2 cond3 cond4]; vars = [alpha, beta];
  sol = solve(conds, [alpha beta], 'ReturnConditions',true);
  soln_alpha = vpa(sol.alpha)
  soln_beta = vpa(sol.beta)
  </code></pre>
  
  <p>The above code returns a numeric answer only if the constraint that &alpha;>0 is relaxed. The numeric answer has a negative value of &alpha; which is wrong since both &alpha; (shape parameter) and &beta; (scale parameter) must be strictly positive.</p>