How can I find the expected value of this variable?

The initial cost of a machine is $ 3. The life-time, T, of that machine has an exponential distribution with an expected value equal to 3 years. The maker wants to offer a warranty that pays $ 3 if the machine gets broken during the first year, $ 2 if the machine gets broken during the second year, and $ 1 if the machine gets broken during the third year.

I know that T ~ Exp(1/3) and that the warranty payment function looks like this:

X = 3 (for T <= 1), 2 (for 1 < T <= 2), 3 (for 2 < T <= 3)

To find E[X] I tired the following: 3*P(T <= 1) + 2*P(1 < T <= 2) + 3*P(2 < T <= 3), which gives me approximately 1.402. However, I don’t know if that is the right way to do it.

Set value in lookup field in workflow?

how can I set only the one value to required lookup field, when I create new item in workflow. I tried use workflow variable, ID but I do something still wrong.

So I have one list A wiht values AB, AC, AD etc. On list B when I select yes in choise field, workflow create new item in list C, where is also lookup field (required) with value from list A. And I only want to set value AB for every created items. Workflow ends with error: Coercion Failed: Unable to transform the input lookup data into the requested type. I found that I used wrong data type, but I don´t know what to do. My workflow set

How to pass contextual id value from one view page to another through Drupal menuing system

  1. I use a view to display a list of books.
  2. The view has three pages: /books/title, /books/date, and /books/popularity.
  3. The pages are essentially the same with different sort criteria.
  4. The pages use a contextual filter to select books by topic based on a taxonomy.
  5. The contextual filter is set to use the query parameter topic when the filter value is not in the URL.
  6. Each page of the view includes a Drupal menu block with the items “By Title”, “By Date”, and “By Popularity” and links /books/title, /books/date, and /books/popularity.
  7. If I invoke /books/title?topic=5 (where 5 is the tid for the “health” topic)
    • A list of health books is correctly displayed.
    • The “By Title” <li> element in the menu is given the active and active-trail classes by the menuing system (which allows the use of CSS to highlight the active menu entry on-screen).
  8. When I’m at /books/title?topic=5 and click the “By Date” menu entry, /books/date is invoked, so the topic id 5 is not passed to the “By Date” view (unsurprisingly), resulting in a list of all books sorted by date instead of just health books sorted by date.


How can I pass the contextual filter value (5 in this example) from one page to another via the menu? For example, if at /books/title?topic=5 I click “By Date”, I want to go to /books/date?topic=5. How can I set that up?


  1. This post is similar to an earlier one where I asked how to get the value coming through the contextual filter. I solved that. There is a twig variable available, in this case, {{ arguments.field_topic_target_id }}.
  2. I used this twig value to rig up my own menu. But having done that, I find that I need the goodness of the Drupal menuing system, both because it makes it easy for editors to change menu items and because it handles the addition of the active and active_trail classes to the proper menu entry.
  3. I have read and tried dozens of approaches to passing the filter value received on to another page via a menu, but none have been effective.


Assuming this problem can be solved, I’d really like to use clean URLs. So instead of /books/title?topic=5 I want to use /books/title/5. This works to correctly display a list of health books sorted by title, but when used, the menuing system does NOT set the active and active_trail classes on the active menu <li>, which I need it to do.

Compile cells when cell contains certain value

In Google Sheets, I have a range of values as follows:

enter image description here

I am looking for a formula that will search the range, find all of the cells that is a ‘wire’ (contains the term “wire”) and outputs the range to a compiled list of all of the wires in the A column list like this:

enter image description here

I could tell you what I’ve tried, but I haven’t even gotten close, so I feel it’s irrelevant.

Here is a copy of the example spreadsheet for copy-paste if needed:

Unable to save ArrayList value in Shared Preference in Andorid

Can any one help me whats wrong in my code unable to save ArrayList document value in shared Preference getting null value in Debug of Array List Document

please help me

Thanks in advance

here is my JSON response

{    "errCode": 0,    "message": "Success",    "responseDestinationDocument": [        {            "name": "United Arab Emirates",            "document": [                {                    "name": "Passport Front",                    "id": "2",                    "notes": [                        {                            "name": "Upload colored passport copies."                        },                        {                            "name": "Passport should be valid 6 months from the date of entry in Sri Lanka."                        },                        {                            "name": "DDDDDDD"                        }                    ]                },                {                    "name": "Passport Back",                    "id": "3",                    "notes": [                        {                            "name": "Upload colored passport copy."                        }                    ]                },                {                    "name": "Photograph",                    "id": "4",                    "notes": [                        {                            "name": "Upload photograph with white background"                        }                    ]                }            ]        }    ] } 

I want to save ArrayList document value in shared Preference

Here is activity code

public void documentRequiredCall() {          Call<DocumentFetchModel> call = RetrofitClient                 .getInstance().getApi().documentFetchModel(booking_id, count_index);          showProgressDialog();         call.enqueue(new Callback<DocumentFetchModel>() {              @Override             public void onResponse(Call<DocumentFetchModel> call, retrofit2.Response<DocumentFetchModel> response) {                 final DocumentFetchModel documentFetchModel = response.body();                 hideProgressDialog();                   PrefUtils.setDocId(documentFetchModel.getResponseBookingDocument().get(0).getDocument(), UploadDocumentsActivity.this);                   if (documentFetchModel.getErrCode().booleanValue() == true) {                      responseBookingDocumentArrayList = new ArrayList<ResponseBookingDocument>();                       try {                          Log.e("Booking_Document", new Gson().toJson(response.body()));                        } catch (Exception e) {                         e.printStackTrace();                     }                   } else {                      Toast.makeText(UploadDocumentsActivity.this, documentFetchModel.getMessage() + "", Toast.LENGTH_SHORT).show();                 }             }              @Override             public void onFailure(Call<DocumentFetchModel> call, Throwable t) {                  hideProgressDialog();                 Toast.makeText(UploadDocumentsActivity.this, t.getMessage() + "", Toast.LENGTH_LONG).show();                 Log.e("Error", t.getMessage() + "");             }         });       } 

Here is PrefUtils Class

public class PrefUtils {   public static DocumentFetchModel getDoc(Context ctx) {         ComplexPreferences complexPreferences = ComplexPreferences.getComplexPreferences(ctx, "get_doc", 0);         DocumentFetchModel currentUser = complexPreferences.getObject("docs", DocumentFetchModel.class);         return currentUser;     }      public static void setDoc(DocumentFetchModel currentUser, Context ctx) {         ComplexPreferences complexPreferences = ComplexPreferences.getComplexPreferences(ctx, "get_doc", 0);         complexPreferences.putObject("docs", currentUser);         complexPreferences.commit();     }      } 

Drupal 8 Webform Issue with Drop Down and Key not Equaling Value

I have written a custom handler in Drupal 8 D8 that grabs submitted data from a webform and reformats it and sends it to a JSON webservice. That is all working perfectly. My issue is that the submitted data from 2 of the dropdowns is an integer (the key of the dropdown), rather than the value of the drop down, like it was when in D7 I called:

$ components = $ node->webform[‘components’];

which gave me the value of the data from the dropdowns. Now I am calling:

$ values = $ webform_submission->getData();

Which gives me the submission data. However, what I need to do is translate the number to the value. For example:

for a component (or element) drop down called ‘numbers’ the options are: 1|One 2|Two 3|Three

When I grab the submission data I get “1” but I want to send the word “One”.

How do I load the dropdown element to translate the value ‘1’ to the word “One” in Drupal 8?


Bind incoming integer value to mat-radio-button value in formgroup

I am loading integer type values from a db to populate a formgroup’s radio buttons. The radio-group only reads values if I convert the incoming integers to strings. How can make the mat-radio-group accept integer values?

I have tried changing value="1" to [value]="1" but that had no effect. The only reference to this I could find was an issue on the material2 github page here


 <form class="mb-4" [formGroup]="wifiForm">         <label id="wifi_available">Is working WiFi present on the property?</label>         <mat-radio-group           aria-labelledby="wifi_available"           class="list-radio-group w-100 mb-4 mt-2"           formControlName="wifi_available"           name="wifi_available"           fxLayout="column"           required         >           <mat-radio-button class="list-radio-button" color="primary" [value]="1">Yes</mat-radio-button>           <mat-radio-button class="list-radio-button" color="primary" [value]="2">No</mat-radio-button>           <mat-error *ngIf="wifiForm.controls.wifi_available.hasError('required').required && wifiForm.controls.wifi_available.touched" class="error"             >Required field</mat-error           >         </mat-radio-group> of form...  </form> 


ngOnInit() {     this.wifiForm ={       wifi_available: ['', Validators.required],       wifi_deadspots: ['', Validators.required],       wifi_notes: [''],     });     this.orderId = this.route.snapshot.paramMap.get('id');     this.wifiData =['order_data']; <== WHERE DATA IS BROUGHT IN     this.wifiForm.patchValue(this.wifiData); <== WHERE DATA IS PATCHED   } 

Values coming in from db [example] { wifi_available: 1, wifi_deadspots: 1, wifi_notes: ‘Lorem bacon…’ }

I am expecting the mat-radio-buttons to be checked accordingly (if 1, then “Yes” checked). If I changed the db field type to VARCHAR the radio-buttons are checked as expected. If the db fields are INT (as they should be) then no radio-buttons are checked.

How to get Magento 2 attribute value in cart?

I cannot get attribute value in checkout/cart in Magento 2.

I use the following code in customer orders page and I get the value but not in checkout/cart page.

This line return null : var_dump($ attribute->getFrontend()->getValue($ product));

$  _item = $  block->getItem(); $  product = $  _item->getProduct(); $  productAttributes = $  product->getAttributes(); $  attributeSetId = intval($  product->getAttributeSetId()); $  obj = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Catalog\Model\Config $  config */ $  config= $  obj->get('Magento\Catalog\Model\Config'); $  group_id = $  config->getAttributeGroupId($  attributeSetId, 'Display Attributes');  foreach ($  productAttributes as $  attribute) :     if ($  attribute->isInGroup($  attributeSetId, $  group_id)) :         var_dump($  attribute->getFrontendLabel());         var_dump($  attribute->getFrontend()->getValue($  product));     endif; endforeach; 

The attribute is visible for products lists and catalog.

Do you know why I can’t get the value in this page ?

Trying to scrape stock price using BeautifulSoup from bloomberg and keep getting the value None

from bs4 import BeautifulSoup import requests  def getstockprice(url):     res = requests.get(url)     soup = BeautifulSoup(res.text, 'html.parser')     elems = soup.select_one('.priceText_1853e8a5')     print(elems)  price = getstockprice('') print ('the stock price is' + str(price))  <span class="priceText__1853e8a5">88.73</span>  

I’m trying to pull the stock price of a stock through a simple script but I’m having trouble pulling it up as it always comes up as the value None. Any ideas? I included the html class I’ve been trying to use to select it via beautifulsoup.