3
$\begingroup$

I have been trying to find a set of parameters for a function that fit some constraints.

FindInstance[
 -a*PDF[NormalDistribution[24, σ], 1] + b == 20 &&
 -a*PDF[NormalDistribution[24, σ], 24] + b == 3 &&
 Total[Table[-a*PDF[NormalDistribution[24, σ], x] + b, {x, 47}]] == 350,
 {a, σ, b}, Reals]

I am trying to solve for a function in the form of

-a*PDF[NormalDistribution[24., σ], x] + b

with the following constraints:

-a*PDF[NormalDistribution[24., σ], 1] + b == 20
-a*PDF[NormalDistribution[24., σ], 24] + b == 3
Total[Table[-a*PDF[NormalDistribution[24, σ], x] + b, {x, 47}]] == 350

The cell has been evaluating for 26 hours and still hasn't given me a result. Could you please guide me on how to edit the code to give me a faster result?

$\endgroup$
1
  • $\begingroup$ Seems an XY problem perhaps. $\endgroup$
    – ciao
    Commented Aug 12 at 22:58

1 Answer 1

5
$\begingroup$
$Version

(* "14.1.0 for Mac OS X ARM (64-bit) (July 16, 2024)" *)

Clear["Global`*"]

sol1 = NSolve[{
   -a*PDF[NormalDistribution[24, σ], 1] + b == 20,
   -a*PDF[NormalDistribution[24, σ], 24] + b == 3,
   Total[Table[-a*PDF[NormalDistribution[24, σ], x] + b, {x, 47}]] == 
    350, σ > 0}, {a, b, σ}, Reals, WorkingPrecision -> 50]

(* {} *)

There is no solution. Reformulate as a minimization.

obj = Total[(SubtractSides[{
        -a*PDF[NormalDistribution[24, σ], 1] + b == 20,
        -a*PDF[NormalDistribution[24, σ], 24] + b == 3,
        Total[
          Table[-a*PDF[NormalDistribution[24, σ], x] + b, {x, 47}]] == 
         350}][[All, 1]])^2];

The approximate solution is then

sol2 = N[NMinimize[{obj, σ > 0}, {a, b, σ}, 
   WorkingPrecision -> 50,
   Method -> "NelderMead"]]

(* {4.02864, {a -> 381531., b -> 1164.26, σ -> 130.873}} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.