pr.probability – Standard Deviation of the Expected Number of Bernoulli Trials Needed for N successes in a row?

The Expected Number of Bernoulli Trials Needed for $n$ successes in a row for any $p$ was answered by a member on math.stackexchange, and also found in this writeup on page two: https://courses.cit.cornell.edu/info2950_2012sp/mh.pdf

Let $A_n$ be the expected/average/mean number of coin flips/bernoulli trials with probability of success $p$ to get $n$ number of heads in a row.

$large A_n=frac{p^{−n}−1}{1−p}$

Do the Binomial Distribution formulas for the mean, variance and standard deviation work for this An formula that was found?

Can I assume the variance is just $σ^2=μ(1−p)$ with $μ=A_n$?

If yes, then the standard deviation is $σ=sqrt{μ(1−p)}$ with $μ=A_n$

I am not sure it is this straightforward because our expression for the mean is more complex than just np.

❕NEWS – Paraguayan Lawmakers Present a Very Different Bitcoin Bill Than Expected | Proxies123.com

Last week, a group of Paraguayan MPs introduced a “Bitcoin bill” in the National Congress, but it turned out to be rather different from what crypto enthusiasts had hoped for. The measure aims to regulate and manage cryptocurrency transactions as well as impose taxes. The proposal makes no mention of designating bitcoin or other cryptocurrencies to be legal money.

algorithms – Prove that the expected length $E [n_{h(k)}]$ of the list containing key $k $ is at most $1 + alpha$

Theorem: Suppose that a hash function $h$ is chosen from a universal collection of hash functions and is used to hash n keys into a table $ T$ of size $m$, using chaining to resolve collisions. If key $k$ is not in the table, then the expected length $E (n_{h(k)})$ of the list that key $k$ hashes to is at most $alpha$. If key $k$ is in the table, then the expected length $E (n_{h(k)})$ of the list containing key $k$ is at most $1 + alpha$.

Solution: (Courtesy to Introduction to Algorithms book):

We note that the expectations here are over the choice of the hash function, and do not depend on any assumptions about the distribution of the keys. For each pair $k$ and $l$ of distinct keys, define the indicator random variable $ X_{kl}=I{h(k) = h(l)}$. Since by definition, a single pair of keys collides with probability at most 1/m, we have $Pr{h(k) = h(l)}le frac{1}{m}$, so $E(X_{kl}) le frac{1}{m}$.

Next we define, for each key $k$, the random variable $ Y_k$ that equals the number of keys other than $k$ that hash to the same slot as $k$, so that

$$
Y_k=sum_{begin{array}{c}
iin T\
lne k\
end{array}}{X_{kl}}
$$

Thus we have
$$
Eleft( Y_k right) =Eleft( sum_{begin{array}{c}
iin T\
lne k\
end{array}}{X_{kl}} right) le sum_{begin{array}{c}
iin T\
lne k\
end{array}}{frac{1}{m}}
$$

So, have 2 cases here,

  1. When $k$ is NOT table $T$: If $k notin T$ , then $n_{h(k)} = Y_k$ and $|{l : l in T ~and~ l ne k}| = n$. Thus $ E (n_{h(k)}) = E(Y_k) le n/m = alpha$, where $h(k)$ is the hash function that hashes $k$ to a slot. $h(k)$ is a simple division method.
  2. When $k$ in table $T$: If $k in T$ , then because key $k$ appears in list $T(h_{(k)})$ and the count $Y_k$ does not include key $k$, we have $n_{h(k)} = Y_k +1$ and $|{l : l ∈ T ~and~ l ne k}| = n −1$. Thus $E(n_{h(k)}) = E(Y_k)+1 le (n−1)/m+1 = 1+ alpha −1/m < 1 + alpha$.

Problem: I would like to discuss case 1 above please. Why this is the case that we have $ E (n_{h(k)}) = E(Y_k) le n/m = alpha$ please?

certificates – Are problems expected when a subdomain CNAME target has no CAA record?

Consider the following DNS setup of example.com:

       A       89.41.169.49                # this is for redirect.pizza
       CAA     0 issue "letsencrypt.org"
www    CNAME   ghs.googlehosted.com

If I have understood correctly everything I read (in particular, https://serverfault.com/q/885952/), the CAA for www.example.com is taken from the one for ghs.googlehosted.com. However, ghs.googlehosted.com does not have a CAA record, and Google does not use Let’s Encrypt.


Edit: I just noticed that that while ghs.googlehosted.com does not have a CAA, googlehosted.com does have one.

  1. So, will the one from googlehosted.com be used for www.example.com?

I believe, no:

If a domain name is a CNAME (also known as an alias) for another domain, then the certificate authority looks for the CAA record set at the CNAME target (just like any other DNS lookup). If no CAA record set is found, the certificate authority continues searching parent domains of the original domain name.

https://sslmate.com/caa/about

This is also in line with SSL Labs displaying the CAA for example.com for www.example.com.

So assume “no” in the following.


  1. So will the one from example.com be used for www.example.com?

(I suspect yes, see the quote above.)

  1. Is this a problem?

(I guess yes.)

If so, let’s go one step further: assume ghs.googlehosted.com does use a CAA record at one point, and all is fine. When the admins of ghs.googlehosted.com delete their CAA entry at one point, thinking that this will relax requirements – will this effectively make the requirements stricter, as now the one from example.com is used?

expected value – Intuitive Probability Card Game

I heard this game from a friend. Note that I am not looking for numerical answers specifically but it would be helpful if someone could come up with one.

Background

You and your friend have a deck of cards 1-100 and you both have 100 dollars. You each pick a card but can’t look at it. However you can look at each other’s card. After looking at your friend’s cards you decide whether you want to bet 1 dollar whether your card is higher than the card you saw. To start us off, the friend will always bet when you bet and both cards will always return to the pile.

Question 1: What will be your strategy if time to complete the game is not an issue? What would be the expected number of games for you to win based on this strategy?

Question 2: If time to completion is important what strategy would you follow? In this case what would be the expected number of games to win?

Question 3: Now suppose that the friend will only accept the bet when he sees that your card is under 50 and you know this is your friend’s strategy. How will you modify your strategy to modify your chances of winning? What would be expected number of games to win?

Question 4: Now suppose that cards with numbers 1-50 are more likely to be dealt to both you and your friend. What will be your strategy then?

Question 5: (My own variation) If the cards are not returned after every draw, that is, you sample without replacement, what should be your strategy? Will it differ from the other cases?

Again note, not looking for numerical answers but would definitely appreciate some kind of relative ordering for the expected games.

Thank you!

xml – for-loop not working as expected for mutilpe repetitive tags – xslt

I’m new to this site.Hope I get help here. I’m currently working on existing requirement. I have to follow the same XSLT pattern of creating a template name and using call-template. here is my below XML:

  <stores>
          <store>
            <books>
              <book>
                <section>1</section>
                <bookinfo>
                  <bookdetails>
                    <A>Author</A>
                    <B>Dreams</B>
                  </bookdetails>
                  </bookinfo>
                  <bookinfo>
                  <bookdetails>
                    <A>Author20</A>
                    <B>Dreams20</B>
                    <loss>
                        <losses>
                            <made>made</made>
                            <amot>amot</amot>
                        </losses>
                         </loss>
                         <loss>
                        <losses>
                            <made>made1</made>
                            <amot>amot1</amot>
                        </losses>
                    </loss>
                    <deducts>
                        <deduct>
                            <pay>pay</pay>
                            <pay1>pay1</pay1>
                        </deduct>
                    </deducts>
                    <deducts>
                        <deduct>
                            <pay>pay1</pay>
                            <pay1>pay2</pay1>
                        </deduct>
                    </deducts>
<perls>
                <perl>
                    <info>perl1</info>
                    <type>typeperl2</type>
                </perl>
            </perls>
            <perls>
                <perl>
                    <info>perl2</info>
                    <type>typeperl3</type>
                </perl>
            </perls>
                  </bookdetails>
                </bookinfo>
              </book>
             </books>
             <books>
              <book>
                <section>2</section>
                <bookinfo>
                  <bookdetails>
                    <A>Author1</A>
                    <B>Dreams1</B>
                    <loss>
                        <losses>
                            <made>made1</made>
                            <amot>amot2</amot>
                        </losses>
                         </loss>
                         <loss>
                        <losses>
                            <made>made2</made>
                            <amot>amot2</amot>
                        </losses>
                    </loss>
                    <deducts>
                        <deduct>
                            <pay>payee</pay>
                            <pay1>pay12</pay1>
                        </deduct>
                    </deducts>
                    <deducts>
                        <deduct>
                            <pay>payee1</pay>
                            <pay1>pay22</pay1>
                        </deduct>
                    </deducts>
    <perls>
                    <perl>
                        <info>perl1</info>
                        <type>typeperl2</type>
                    </perl>
                </perls>
                <perls>
                    <perl>
                        <info>perl2</info>
                        <type>typeperl3</type>
                    </perl>
                </perls>
                </bookdetails>
               </bookinfo>
              </book>
            </books>
          </store>
        </stores>

Here is my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
    <xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="no"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="stores">
          <LocalStore>
      <xsl:for-each select="//books/book">
           <xsl:call-template name="name">
            </xsl:call-template>
        </xsl:for-each>


             </LocalStore>
     </xsl:template>

    <xsl:template name="name">  
     <xsl:variable name="A" select=".//bookinfo/bookdetails/A"/>
      <xsl:variable name="B" select=".//bookinfo/bookdetails/B"/>

      <LocalDetails>
         <xsl:if test="string-length($A) > 0">
         <BookType>
           <xsl:value-of select="$A"/>
              </BookType>
              </xsl:if>

         <xsl:if test="string-length($B) > 0">
           <BookLPP>
               <xsl:value-of select="$B"/>
            </BookLPP>
            </xsl:if>
         </LocalDetails>
         </xsl:template>
         <xsl:template name="name1">
             <xsl:variable name="C" select="../../loss/losses/made"/>   

         <losstype>
           <xsl:value-of select="$C"/>
         </losstype>


</xsl:template>
</xsl:stylesheet>

I have tried in different ways. But still I’m not getting desired output. I will be getting multiple repetitive elements under each <book> and <bookinfo> tags.- I’m mapping each and every element and I want to iterate through each and every element of the incoming request. How can I write this in xslt ?

Here is my desired output:

<LocalStore>
     <LocalDetails>
     <section>1</section>
      <BookType>Author</BookType>
       <BookLPP>Dreams</BookLPP>
       <BookType>Author20</BookType>
       <BookLPP>Dreams20</BookLPP>
         <losstype>made</losstype>
         <lossamt>amot1</lossamt>
         <LPPtype>made1</LPPtype>
         <LPPamot>amot1</LPPamot>
         <LPPdeducts>pay</LPPdeducts>
         <LPPdeducts2>pay1</LPPdeducts2>
         <LPPlevel>pay1</LPPlevel>
         <LPPLevel2>pay2</LPPLevel2>
         <LPPPerl>perl1</LPPPerl>
         <CPPPerl>typeperl2</CPPPerl>
         <CPPerltype>perl2</CPPerltype>
         <CPPerlLevel>typeperl3</CPPerlLevel>
          </LocalDetails>
    <lossdetails>
     <section>2</section>
      <BookType>Author1</BookType>
       <BookLPP>Dreams1</BookLPP>
       <losstype>made</losstype>
         <lossamt>amot1</lossamt>
         <LPPtype>made1</LPPtype>
         <LPPamot>amot1</LPPamot>
         <LPPdeducts>pay</LPPdeducts>
         <LPPdeducts2>pay1</LPPdeducts2>
         <LPPlevel>pay1</LPPlevel>
         <LPPLevel2>pay2</LPPLevel2>
         <LPPPerl>perl1</LPPPerl>
         <CPPPerl>typeperl2</CPPPerl>
         <CPPerltype>perl2</CPPerltype>
         <CPPerlLevel>typeperl3</CPPerlLevel>
     </LocalDetails>
      </LocalStore>

hyperledger fabric – I encountered some problems when I tried to connect the chaincode with the go program.* ‘***.Registrar’ expected a map, got ‘slice’

I wrote the configuration file connect.yaml and tried to connect the chaincode with the go program. But the following error occurred:

2021/08/29 17:10:04 Failed to connect to gateway: Failed to apply config option: failed to initialize configuration: unable to load identity config: failed to initialize identity config from config backend: failed to create identity config from backends: failed to parse ‘certificateAuthorities’ config item to identityConfigEntity.CertificateAuthorities type: 3 error(s) decoding:

  • ‘(ca.agridepart.amops.com).Registrar’ expected a map, got ‘slice’
  • ‘(ca.agrimacowner.amops.com).Registrar’ expected a map, got ‘slice’
  • ‘(ca.financedepart.amops.com).Registrar’ expected a map, got ‘slice’

Then I tried to delete the following content in the certificateAuthorities section in the connect.yaml file

registrar:
     -enrollId: admin
       enrollSecret: adminpw

But the following error occurred:
2021/08/29 17:38:57 Failed to get network: Failed to create new channel client: event service creation failed: could not get chConfig cache reference: QueryBlockConfig failed: QueryBlockConfig failed: target(s) required

So whether the second error is related to the first error and what caused it. what should I do?

The content of my connect.yaml file is as follows:

---
name: amops
version: 1.0.0
client:
  organization: Agridepart
  connection:
    timeout:
      peer:
        endorser: '300'
      orderer: '300'
channels:
  amops:
    orderers:
    - agridepartorderer.amops.com
    - agrimacownerorderer.amops.com
    - financedepartorderer.amops.com
    peers:
      peer0.agridepart.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
      peer0.agrimacowner.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
      peer0.financedepart.amops.com:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
organizations:
  Agridepart:
    mspid: AgridepartMSP
    peers:
    - peer0.agridepart.amops.com
    certificateAuthorities:
    - ca.agridepart.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/users/Admin@agridepart.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/users/Admin@agridepart.amops.com/msp/signcerts/Admin@agridepart.example.com-cert.pem"
  Agrimacowner:
    mspid: AgrimacownerMSP
    peers:
    - peer0.agrimacowner.amops.com
    certificateAuthorities:
    - ca.agrimacowner.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/users/Admin@agrimacowner.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/users/Admin@agrimacowner.amops.com/msp/signcerts/Admin@agrimacowner.amops.com-cert.pem"
  Financedepart:
    mspid: FinancedepartMSP
    peers:
    - peer0.financedepart.amops.com
    certificateAuthorities:
    - ca.financedepart.amops.com
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/users/Admin@financedepart.amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/users/Admin@financedepart.amops.com/msp/signcerts/Admin@financedepart.amops.com-cert.pem"
orderers:
  agridepartorderer.amops.com:
    url: grpcs://192.168.32.165:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: agridepartorderer.amops.com
      hostnameOverride: agridepartorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/agridepartorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
  agrimacownerorderer.amops.com:
    url: grpcs://192.168.32.170:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: agrimacownerorderer.amops.com
      hostnameOverride: agrimacownerorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/agrimacownerorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
  financedepartorderer.amops.com:
    url: grpcs://192.168.32.171:7050
    mspid: OrdererMSP
    grpcOptions:
      ssl-target-name-override: financedepartorderer.amops.com
      hostnameOverride: agrimacownerorderer.amops.com
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/orderers/financedepartorderer.amops.com/tls/ca.crt"
    adminPrivateKeyPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/keystore/priv_sk"
    signedCertPEM:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/ordererOrganizations/amops.com/users/Admin@amops.com/msp/signcerts/Admin@amops.com-cert.pem"
peers:
  peer0.agridepart.amops.com:
    url: grpcs://192.168.32.165:7051
    grpcOptions:
      ssl-target-name-override: peer0.agridepart.amops.com
      hostnameOverride: peer0.agridepart.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/peers/peer0.agridepart.amops.com/tls/ca.crt"
  peer0.agrimacowner.amops.com:
    url: grpcs://192.168.32.170:7051
    grpcOptions:
      ssl-target-name-override: peer0.agrimacowner.amops.com
      hostnameOverride: peer0.agrimacowner.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/peers/peer0.agrimacowner.amops.com/tls/ca.crt"
  peer0.financedepart.amops.com:
    url: grpcs://192.168.32.171:7051
    grpcOptions:
      ssl-target-name-override: peer0.financedepart.amops.com
      hostnameOverride: peer0.financedepart.amops.com
      request-timeout: 120001
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/peers/peer0.financedepart.amops.com/tls/ca.crt"
certificateAuthorities:
  ca.agridepart.amops.com:
    url: https://192.168.32.165:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agridepart.amops.com/ca/ca.agridepart.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw
  ca.agrimacowner.amops.com:
    url: https://192.168.32.170:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/agrimacowner.amops.com/ca/ca.agrimacowner.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw
  ca.financedepart.amops.com:
    url: https://192.168.32.171:7054
    httpOptions:
      verify: true
    tlsCACerts:
      path: "/home/jing/go/src/github.com/fabric-samples/amops/multiple-deployment/crypto-config/peerOrganizations/financedepart.amops.com/ca/ca.financedepart.amops.com-cert.pem"
    registrar:
    - enrollId: admin
      enrollSecret: adminpw

probability – Find the expected value..

Hi i was having a bit of a problem understanding why the professor did what he did. I found this exercise in the solved exercise session in my university solved exercise session.

The problem goes like this:

Each time a button is pressed a machine delivers a plate of plastic material having thickness distributed(independently of the previous time) as an exponential random variable with $gamma =2$. Pressing the key once one obtains a plate of thickness $X_1$. If $X_1 geq frac12 $ we can sell the plate making a profit of 1 euro otherwise he can press the button a second time and get a new plate $X_2$. If $X_2 geq frac12$ we can sell it to make a profit of 0.5 euros and if even $X_2$ is too thin then we discard everything and we gain nothing

We have to find the Expected value

I know generally how to find the expected value but i didnt get where he got some of the numbers from.
Here is what he does

Let G be the gain
$E(G)=1⋅P(G=1)+0.5*P(G=0.5) + 0⋅P(G=0)$

How to find the probabilities of the Gain G being $1$ and $0.5$ and $0$ i know how to do! THe only thing thats confusing me is how he got the $1,0.5,0$

statistics – Showing that the expected value of the estimator is equal to the estimate

I’m reallys struggling with a question I’ve been working on, any help would be super appreciated.

If I were given a random sample from a distribution for which the joint density of that distribution is from the regular exponential family, how would I go about showing that the maximum likelihood estimate (for the case where there is only one parameter) satisfies the equation:

$$Ebig({bf{T}} (X_1,dots,X_n) big) = {bf{T}}(x_1,dots,x_n)$$

My thoughts are to use the expectation of the score statistic equalling zero, but I can’t seem to piece it together.

Thanks guys

probability theory – Expected value of sequence of rv

I’m stuck with this problem.

Let $X_n$ be a sequence of random variables with $X_1$ the random number chosen at $(0,1)$. $X_2$ be the random number chosen at $(1-X_1,1)$ and so on. This is, $X_n$ is the random number chosen at $(1 – X_{n-1}, 1)$. What is $E(X_n)$?

I have used conditional expectation in my first approach and order statistics in the second, but I’m not sure about my interpretation of the problem. Any hint?