Opened 6 years ago

Closed 5 years ago

#1108 closed defect (fixed)

"Writing a Plugin Model" does not explain function "random"

Reported by: Joachim Wuttke Owned by:
Priority: minor Milestone: SasView 4.3.0
Component: sasmodels Keywords:
Cc: Work Package: SasView Documentation

Description (last modified by butler)

Each SasView seems to contain a function "random", on a par with "Iq".

However, I find no explanation of this function on the otherwise well
written and informative page "Writing a Plugin Model" [1].

Could you please point me to an existing explanation of "random", or
briefly improvise such explanation?

Thanks, Joachim

[1] http://www.sasview.org/docs/user/sasgui/perspectives/fitting/plugin.html

Change History (5)

comment:1 Changed 6 years ago by butler

  • Description modified (diff)

Can you elaborate please? I just looked at the documentation and it seems pretty clearly explained (though I have not run

main()

To see all the help it may give as suggested. However to note that "random" is not a SasView function at all but a parameter in the compare framework used for testing models. I think it just calls the built in random number generator to create values for the model parameters within what should be generically "reasonable" bounds for a given parameter type as explained in the documentation:

Options will need to be passed as separate strings. For example to run your model
with a random set of parameters:

main("-random", "-pars", "~/.sasview/plugin_models/model.py")

For the random models,
   sld will be in the range (-0.5,10.5),
   angles (theta, phi, psi) will be in the range (-180,180),
   angular dispersion will be in the range (0,45),
   polydispersity will be in the range (0,1)
   other values will be in the range (0, 2v), where v is the value of the parameter in demo.

A better indication of what is confusing and how to make it more clear to a first time model developer would be helpful and very welcome.

comment:2 Changed 6 years ago by pkienzle

I think the question is what the def random() functions in each of the models/*.py files is for.

The random() function provides a model-specific random parameter set which shows model features in the usans to sans range. For example, core-shell sphere sets the outer radius of the sphere logarithmically in [20, 20,000], which sets the Q value for the transition from flat to falling. It then uses a beta distribution to set the percentage of the shape which is shell, giving a preference for very thin or very thick shells (but never 0% or 100%). Using -sets=10 in sascomp should show a reasonable variety of curves over the default sascomp q range. The parameter set is returned as a dictionary of {parameter: value, ...}. Any model parameters not included in the dictionary will default according to the code in the _randomize_one() function from sasmodels/compare.py.

This description, along with an updated summary of _randomize_one() should be included in sasmodels/doc/guide/plugins.rst. Should we describe the reasons for the choice of distributions I used when writing all the random functions (uniform, 10uniform, and beta)?

comment:3 Changed 6 years ago by smk78

Have just added this definition of random() (word for word) to the bottom of the Model Computation section in plugin.rst

comment:4 Changed 5 years ago by smk78

Ahh. It seems that after addressing this ticket, I forgot to close it! :-)

comment:5 Changed 5 years ago by smk78

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.