I am trying to calibrate the parameters of a Pareto-IV distributions such that it matches some given empirical values (for example the mean and some quantiles). That's not working.
Here is a trivial MWE with only one parameter:
SeedRandom[13];
func[k_] := (data = RandomVariate[NormalDistribution[k, 1], 100];
(Mean[data] - 10])^2)
FindMinimum[{func[k]}, {k, 1}]
I want that Mathematica numerically finds the parameter of the normal distribution that results in an average most close to 100 10. Obviously, the correct solution should be close to 100 10. I get the following error messages
RandomVariate::realprm: Parameter k at position 1 in NormalDistribution[k,1] is expected to be real. >>
RandomVariate::realprm: Parameter k at position 1 in NormalDistribution[k,1] is expected to be real. >>
FindMinimum::sszero: The step size in the search has become less than the tolerance prescribed by the PrecisionGoal option, but the gradient is larger than the tolerance specified by the AccuracyGoal option. There is a possibility that the method has stalled at a point that is not a local minimum. >>
and the wrong output
{78.3109, {k -> 1.}}
I have the feeling that it would be no problem to set this up in Matlab or GAUSS, but why is such a thing not working with Mathematica? Does Mathematica try to evaluate the function symbolically? Am I doing something wrong?
Thanks for your help!
?NumericQ
. But your function definition does not work in Mathematica 10.4.1. (Mismatched parentheses and square brackets) Are you using a different version? Also, each time the functionfunc
is called, you get a new random sample. Is that what you want? $\endgroup$