Sequences and series – Why does this pattern emerge when one randomly fills trays from a pool of total values?

I've written a small function to randomly generate a list of values ​​that total a total, in this case 100; written for some reason. After aggregating the lists and averaging between the indices, I found that the averages showed a trend.

Here 1000 lists, of length 10, where the sum of all the values ​​is 100, have been generated and the average value for each index has been calculated.

$$ l_1 = (50.35, 25.11, 12.33, 6.3, 2.92, 1.47, 0.75, 0.38, 0.18, 0.08) $$

The pattern I've found is that the average value at a specific index is always about half of the last, and the first average is half the total sum of the list.

For example, here is the same calculation on 1000 lists, of length 4, with a sum of list of 50.

$$ l_2 = (24.774, 12.683, 6.265, 3.223) $$

To be complete, here is a Python SSCCE that generates the lists and calculates the averages

import random

def genlist(len, total):
    r = ()
    for i in range(0, len):
        if total == 0:
            r.append(0)
            continue
        v = random.randint(0, total)
        r.append(v)
        total -= v
    return r

list_of_lists = (genlist(4, 50) for i in range(0, 1000))
transpose_lol = zip(*list_of_lists)
avg_index_value = (float(sum(x)) / len(x) for x in transpose_lol)

print(avg_index_value)

Why does this model emerge?

I can see it roughly, just in the way that the "bins" that are the indexes of the list are filled from an increasingly smaller pool. That said, it gives the impression that the random value of the first index is always "big"; it is just as likely that he is small too. So, I keep telling myself that the average indexes in the list should always be fair total/len.

pattern matching – Replaces zeros in a list with the last non-zero value

This question is closely related to the problem of zeroing.

Suppose I have a list l = {-1, -1, 0, 1, 0, 0, -1, -1, 1, 1, 1, 0, 0, 0, -1}

and I want to replace the zeros with the previous non-zero value, like this:

{-1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1}

A rather awkward way of doing this is with:

  f = TimeSeries[l /. 0 -> Missing[], 
MissingDataMethod -> {"Interpolation", InterpolationOrder -> 0}]

So indeed f[-1 + Range@Length@l]gives the required result.

However, there must be a more elegant way to achieve the same result, with reasons.

Can any one provide a suggestion?

google sheets – Need help with a formula: take lines in a column, fill them in two different columns after a pattern and delimiters

First, excuse me if I do not ask you the question properly and if I do not explain it correctly.

I need help for – preferably a formula – (but it could be a script if the choice is nonexistent).

I have a column of lines (A) that I have to fill in B and C with delimiters between and with a particular pattern.

To better explain the result I need, I have created a block of text below as a pseudo-sheet to illustrate.

  • Col A (source) is the data entered manually. Columns B and C (desired result) will have formulas for the lines of A to be filled in according to the model.

  • The motive for B is: fixed number of lines of A, followed by the delimiter "BONJOUR" then the same number of subsequent lines of A again and so on. Model for C is: Text "SET" plus a counter of the number of sets of lines delimited in B. Please note that A may have more (or fewer) lines and that it is not limited to 22 lines. The model will follow.

  • I played with the formula
    =arrayformula( if ( mod( row(A:A), 6 ) = 0, "HELLO", A:A) ) for B but he jumps all six ranks in A, and also I can not understand how to do C at all 🙁

Any help would be greatly appreciated with the formula that achieves the desired result – or, if it is not possible, to give guidance on what I should ask or search properly to achieve that goal. Thank you very much.

        (source)    (  desired result  )

        A           B           C
1       mercury     mercury     SET 1
2       mars        mars
3       jupiter     jupiter
4       venus       venus
5       saturn      saturn
6       six         HELLO
7       jill        six         SET 2
8       earth       jill
9       nine        earth
10      ten         nine
11      eleven      ten
12      nepture     HELLO
13      thirteen    eleven      SET 3
14      fourteen    nepture
15      sarah       thirteen
16      sixteen     fourteen
17      seventeen   sarah
18      earth       HELLO
19      nineteen    sixteen     SET 4
20      twenty      seventeen
21      pluto       earth
22      andrea      nineteen
23                  twenty
24                  HELLO
25                  pluto       SET 5
26                  andrea
...     ...         ...         ...

design – Is the observable pattern the right tool for this scenario?

This seems to be a good use of the observer model, which theoretically dissociates the different types of objects. However, I am not sure that the scenario is enough.

Suppose you have smallTower and bigTower with different resource needs. The orchestration according to your scenario would need to know what type of tower should be built, create the tower object (which knows the necessary resources), then check if the player has enough resources and book it, and then subscribe to tower notifications, build the tower and inform the elements that the tower is built to use the reserved resources.

As you can see, in this scenario, there is interdependence between the tower, the player, and the table before the notification can take place. Especially considering that the tower belongs to the player. It is also strange to have to subscribe to the new object before you can make sure it can be built.

I suggest to consider the use of the generator model (beware: the GoF generator, not the Bloch model). The responsibility of this object would be to verify that the building is feasible and then orchestrate the relationship between the board, the tower and the player.

This builder should know the interface of the 3 objects and would depend on them. But the other objects would remain as coupled as possible.

You could always have an observer for all the events that might interest the tower (completed tower, damaged tower, destroyed tower).

3.5nd dnd – What is the caster level of a creature summoned with the Greenbound pattern?

The Greenbound pattern gives your summoned creatures the ability to cast spell-like abilities at will, with the following description:

The caster level is equivalent to the character level of the creature linked to the green; save DC 10 + spell level + charisma modifier of the creature linked to the greenery.

Now, Greenbound gives the +8 level setting. Some models have no level adjustment. Others have some here and there.

So, help a noobie, what is the "level" resulting from your invocation of Nature Summon's Ally, if only to know the level of the caster in this case?

replacement – Replaces subexpressions that match a pattern, unless they are under specific headers

Suppose I have a rule, for example Re(x_) :> (x + Conjugate(x))/2. I want to apply it to all the corresponding subexpressions of an expression, excluding subexpressions located somewhere under the heads. Hold(…) or Function(…) (at any depth). What is the easiest way to do it? Can we do this without explicit filtering of positions?

Aggressive Geometry – Do regular (but not smooth) conics on a value field distinct from the $ 2 $ feature admit a regular pattern on the valuation ring?

Let K $ to be a field of character not perfect $ 2 $. Let $ T subseteq K $ to be a discreet evaluation ring.
Assume that there is $ a, b in K ^ { times} $ such as the projective conic $ C $ Defined by $$ aX ^ 2 + b Y ^ 2 + Z ^ 2 = 0 $$ does not contain K $rationalization point
(in particular $ a, b $ and $ ab $ are not squares K $). then $ C $ is not smooth on K $ at each point. however, $ C $ is regular (see exercise 4.3.22d) of Qing Liu's book Algebraic geometry and arithmetic curves).

Question: Is $ C $ have a regular projective model on $ T $ (that is, a regular fiber-optic projective surface on $ T $ with generic fiber isomorphic to $ C $)?

Each smooth curve on K $ admits a regular projective model on $ T $, as indicated (for example) in Corollary 8.3.51 of Liu's aforementioned book.
This seems to be based on Lipman's resolution of the singularities of $ 2 $-dimensional excellent Noetherian patterns, applied to a normal pattern of the curve on $ T $, or rather a basic change at the end of $ T $ (Excuse the sloppy description, it may not be a very accurate description of what is really happening).
In any case, it seems crucial to use the fact that the generic fiber of the normal model is not only regular, but smooth K $.

Nevertheless, this is a general assertion and it is a priori possible that, in concrete cases of regular projective curves (such as all integral and regular conics K $, which interests me), there are regular projective models on $ T $, whether the regular curve is smooth or not K $ or not.

objective – What are the causes of this repetition pattern in an image? (when reorganizing its pixels by their intensity – code included)

Just out of curiosity, I played with the RGB coordinates and pixels of the images. Then, for some reason, I decided to get all the pixels of an image, to get the coordinates / RGB values ​​of each pixel (for example, RGB (120, 30, 15)), to add the coordinates (for example, 120 + 30 + 15 = 165). ), then sort the pixels in ascending order according to this number (the sum of the coordinates / RGB values ​​of the pixel).

So, to be able to visualize this, I have "printed" the pixels on another image of the same dimensions as the original, but with the rearranged pixels as content. See an example below (and the corresponding Ruby code).

You will notice that the output image has a very well defined pattern. I've tried the same thing (rearrange the pixels by R + G + B) with a lot of different images, and there is always a similar pattern of repeating smaller versions of the same image.

Why does this happen? What explains the pattern of the image when the pixels are rearranged?

Original image:
enter the description of the image here

Image with rearranged pixels:
enter the description of the image here

# Ruby code
require 'rmagick'
include Magick

img = ImageList.new("images/test-image.jpg")
pixels = img.get_pixels(0,0,img.columns,img.rows)

# Sort pixels by total intensity
pixels = pixels.sort {|p| p.red + p.green + p.blue}

out_img = Magick::Image.new(img.columns, img.rows)
out_img.store_pixels(0,0, img.columns, img.rows, pixels)
out_img.write("images/test-image-out.jpg")

@ cthom06 understood it in the comments. The code above uses sort instead of sort_by to sort the pixel array. Always curious to know what sort made.

Someone answered the question on dsp: How would you interpret the pattern in this picture? (generated by re-sorting the pixels according to their RGB value)

When using sort_by, the output image looks like this:
enter the description of the image here

spells – How long is a creature fascinated by a hypnotic pattern?

Hypnotic Pattern says that when one of the triggers is triggered, an affected creature performs a testamentary save, and if it fails, it becomes fascinated. No duration, just fascinated. Is it until he leaves the motif? For the duration of the reason? As long as he can see the pattern? As long as he continues to do one of the things that trigger a backup of the will?

Nokia 7.1 Pattern Lock thought even to have given the correct code of access

I'm using a Nokia 7.1 mobile phone. I have the lock pattern of the configuration screen and the fingerprint.
Now I have a problem with the phone, as not being able to unlock it even if I give a correct passcode and fingerprint.
Now, I do not know how to solve this problem in Nokia 7.1 phone, please suggest to solve the problem. I have been restarted several times and I do not want to do any factory reset.

Thank you in advance.