Author Topic: using uq module as a standalone tool  (Read 6704 times)

Anne Hulsey

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
using uq module as a standalone tool
« on: October 12, 2022, 09:23:04 AM »
Hello. I would like to use the uq module to create a truncated lognormal fragility curve. I currently use stats.lognorm(beta, scale=median).pdf(x) to get a lognormal fragility curve so I'm hoping for something that could give me a similar result but with a truncation. Any suggestions?

Sang-ri

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
Re: using uq module as a standalone tool
« Reply #1 on: October 12, 2022, 05:31:49 PM »
Hi Anne,

Thanks for asking this! Can you help us better understand the task by giving more details or maybe pointing us to a reference that shows your objective?

For example, we are wondering:

1. Do you need to 'calibrate' the truncated lognormal or do you want to 'sample' from it using quoFEM (or is it both)? If it is the former, it would be helpful if we knew the type of dataset used to calibrate the fragility curve. If it is the latter, we can provide a new distribution in the RV panel.

2. Do you consider this only in quoFEM, or are you envisioning using the truncated lognormal distribution on EEUQ and other tools as well?

Sang-ri

Anne Hulsey

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: using uq module as a standalone tool
« Reply #2 on: October 12, 2022, 08:10:20 PM »
Hi Sang-ri, thanks for the quick response!

1. I handle the uncertainty in my own way and do not intend to use uq's functionality for that. The only reason I would add the module (for my current project, at any rate) is to sample a truncated lognormal distribution in place of the standard lognormal distribution. I would like to see the difference in annual risk when convoluting the two fragility curves with a hazard curve.

2. I don't think this is applicable, as I am not using the tools at all, except for this purpose. I would need to be able to use it in a Jupyter Notebook.

Adam seemed to think this was possible. Unfortunately my timeframe is very short. If I can't get this working by the end of the week, I will have to come up with a different solution.

Thanks,
Anne

Sang-ri

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
Re: using uq module as a standalone tool
« Reply #3 on: October 12, 2022, 10:42:48 PM »
Hi Anne,

Thanks for the clarification. If you simply need to generate samples from a truncated lognormal distribution, I would not recommend you use quoFEM (Although we can do it by generating standard uniform samples and providing a model that transforms the samples to truncated lognormal space)

Instead, to my understanding, the 'rejection sampling' described below seem to be the quickest way of getting samples from truncated lognormal:
1. Generate a larger set of samples from the original lognormal distribution, for example, using stats.lognorm.rvs()
2. Discard all the samples below the truncation threshold and use only the ones within the valid range.

Please let me know if I am missing something or if you wanted to get the PDF or CDF of the truncated lognormal distribution instead of its samples.

Thanks,
Sang-ri

Anne Hulsey

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: using uq module as a standalone tool
« Reply #4 on: October 12, 2022, 11:30:44 PM »
Thanks, Sang-ri! I will check in with Adam as well but this seems like a good solution. Much appreciated.

fmk

  • Administrator
  • Full Member
  • *****
  • Posts: 232
    • View Profile
Re: using uq module as a standalone tool
« Reply #5 on: October 13, 2022, 04:09:47 PM »
if using the dakota option in quoFEM, you can use the dakota.in file generated by a dummy run of the tool and modify that dakota input file to put lower (and upper) bounds on the lognormal random variables.

https://dakota.sandia.gov/sites/default/files/docs/6.10/html-ref/variables-lognormal_uncertain.html

for future users, the lower and upper bounds could be added to quoFEM if deemed useful?

adamzs

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Re: using uq module as a standalone tool
« Reply #6 on: October 14, 2022, 11:26:36 PM »
Hi Anne,

sorry for joining this conversation a little late.

When I suggested the uq module, I meant the uq module of Pelicun. That supports truncated distributions out of the box.

The rejection sampling that Sang-ri suggested works for a single variable. It is somewhat inconvenient that you need a larger sample to make sure you have enough data left after rejecting the points outside your domain of interest, but that is not a big issue. However, when you want a correlated multivariate truncated distribution, rejections can lead to a very different correlation structure than what you get if you define them using a Gaussian copula between the truncated marginals. Neither solution is 'correct', but the two solutions are different.

Re Frank's question, I think lower and upper limits on any random variable could be useful to have in quoFEM.

Adam

Anne Hulsey

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
Re: using uq module as a standalone tool
« Reply #7 on: October 17, 2022, 11:41:35 PM »
To follow up, Adam provided me with a notebook to use pelicun's uq module and it worked perfectly. Thanks all.