Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Writing a Plugin Model" does not explain function "random" (Trac #1108) #178

Closed
sasview-bot opened this issue Mar 30, 2019 · 5 comments
Closed

Comments

@sasview-bot
Copy link

sasview-bot commented Mar 30, 2019

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

Migrated from http://trac.sasview.org/ticket/1108

{
    "status": "closed",
    "changetime": "2019-03-25T10:34:28",
    "_ts": "2019-03-25 10:34:28.942736+00:00",
    "description": "Each !SasView seems to contain a function \"random\", on a par with \"Iq\".\n\nHowever, I find no explanation of this function on the otherwise well\nwritten and informative page \"Writing a Plugin Model\" [1].\n\nCould you please point me to an existing explanation of \"random\", or\nbriefly improvise such explanation?\n\nThanks, Joachim\n\n[1] http://www.sasview.org/docs/user/sasgui/perspectives/fitting/plugin.html",
    "reporter": "Joachim Wuttke",
    "cc": "",
    "resolution": "fixed",
    "workpackage": "SasView Documentation",
    "time": "2018-06-07T09:13:56",
    "component": "sasmodels",
    "summary": "\"Writing a Plugin Model\" does not explain function \"random\"",
    "priority": "minor",
    "keywords": "",
    "milestone": "SasView 4.3.0",
    "owner": "",
    "type": "defect"
}
@butlerpd
Copy link
Member

Trac update at 2018/06/07 10:03:01:

  • butler commented:

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.

  • butler changed description from:

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

to:

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

@pkienzle
Copy link
Contributor

Trac update at 2018/09/18 03:14:19: pkienzle commented:

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, 10^uniform^, and beta)?

@smk78
Copy link
Contributor

smk78 commented Mar 30, 2019

Trac update at 2018/09/18 09:41:51: smk78 commented:

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

@smk78
Copy link
Contributor

smk78 commented Mar 30, 2019

Trac update at 2019/03/25 10:34:16: smk78 commented:

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

@smk78
Copy link
Contributor

smk78 commented Mar 30, 2019

Trac update at 2019/03/25 10:34:28:

  • smk78 changed resolution from "" to "fixed"
  • smk78 changed status from "new" to "closed"

@butlerpd butlerpd modified the milestones: SasView 4.3.0, sasmodels 0.99 May 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants