text:
## Binding two objects

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Lirija
Prole
Posts: 28
Joined: Tue Mar 14, 2017 11:42 am
Contact:

### Binding two objects

I'm sorry that i did't found a better way to explain this:
i'd like to have some objects work "in tandem" such as a switch that when triggered opens a particular gate or two tiles that teleport the player from one to another, do you have any suggestion on how i can accomplish this?
Last edited by Lirija on Tue Apr 17, 2018 11:31 am, edited 1 time in total.
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

### Re: Make two objects "work together"

I think you're overthinking this... Start with the doors:

Code: Select all

function newDoor(x, y)
return {
x = x or 0,
y = y or 0,
closed = true,

interact = function() closed = not closed end
}
end

-- Then you can place them, for simplicity we'll pretend x and y are tile locations
local doors = {}

for i = 1, 10 do
table.insert(doors, newDoor(math.random(1, 10), math.random(1, 10)))
end

Then make the triggers for the player to step on.

Code: Select all

function newTrigger(x, y, door)
return {
x = x or 0,
y = y or 0,
door = door or nil,

interact = function()
if door then door:interact() end
end
}
end

local triggers = {}

for i = 1, 3 do
table.insert(triggers, newTrigger(math.random(1, 10), math.random(1, 10), doors[math.random(1, #doors)])
end

Whenever the player moves loop over the list of triggers to see if they're on one. If they are, invoke the interaction.

Code: Select all

for i, v ipairs(triggers) do
if player.x == v.x and player.y == v.y then
v.interact()
return
end
end

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end

GitHub -- Website
Lirija
Prole
Posts: 28
Joined: Tue Mar 14, 2017 11:42 am
Contact:

### Re: Make two objects "work together"

Thank you! Your explanation was crystal clear!
Just another question: if i want to place the interacting objects using tiled and i have more than one pair in the same map how could i bind them correctly? (the only thing i can think of is give them a name like "object door 1" and using string patterns methods later to assign the door to the corresponding switch)
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

### Re: Binding two objects

Maybe someone else can be more help here... I haven't used Tiled much other than a making static map. The code I provided won't throw an error if the player steps on a trigger that isn't connected to a door. The trick is to pass the door reference to the trigger, then the trigger interacts with the specific door directly. One way or another Tiled won't be able to do everything, and you'll have to link them together eventually. Then again take this with a grain of salt, because as I said, I'm not very experienced with Tiled.

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end

GitHub -- Website

### Who is online

Users browsing this forum: No registered users and 47 guests

format: plain


text:
# The vertex form of the equation of a parabola is y=(x+5)^2+49. What is the standard form of the equation?

Jun 26, 2017

I am afraid that both previous answers are wrong, at least partially. The answer is : $y = {x}^{2} + 10 x + 74$

#### Explanation:

So, to understand how to get to this solution, I strongly advise to read the answer wrote by "Anonymous". Just be careful for the last step : 49+25 = 74 and not 64.

Concerning the answer from "9divine9 I.", the first solution is right but I must say that I have no idea how he found the 3 others solutions... which are wrong !
As evidence, look at the following plots :

In red -> the vertex form of the equation given in the question
In green -> the solution (standard form)
N.B : As you can see both are matching perfectly !

In blue : the 2nd solution proposed by "9divine9 I."

And now, the plot of the 3 others solutions proposed by "9divine9 I.", just to compare that none of them match each other.


text:
• Home
• /
• Blog
• /
• Volume of a Cone(Formula, Derivation & Examples)

# Volume of a Cone(Formula, Derivation & Examples)

September 26, 2022

A cone is a 3D shape with a curved surface and a flat circular surface. One of the most common real-world examples of a cone are ice-cream cones are party hats.

The space occupied by a cone is called the volume of a cone. It’s also referred to as the capacity of a cone and it depends on the radius and the height of the cone. Volume of a cone is measured in terms of cubic units, such as $cm^{3}$, $m^{3}$, $mm^{3}$, $in^{3}$, $ft^{3}$, etc.

Let’s learn how to find the volume of a cone and its formula.

## What is the Volume of a Cone (Volume of Right Circular Cone)?

The volume of a cone is the number of cubic units, occupied by the cone completely. The unit of volume of a cone is cubic units such as $cm^{3}$, $m^{3}$, $mm^{3}$, $in^{3}$, $ft^{3}$.

If the measure of radius and height of a cone are $r$ and $h$ unit, then the formula for calculating its volume is $\frac {1}{3}\pi r^{2} h$.

Is your child struggling with Maths?
We can help!
Country
• Afghanistan 93
• Albania 355
• Algeria 213
• American Samoa 1-684
• Andorra 376
• Angola 244
• Anguilla 1-264
• Antarctica 672
• Antigua & Barbuda 1-268
• Argentina 54
• Armenia 374
• Aruba 297
• Australia 61
• Austria 43
• Azerbaijan 994
• Bahamas 1-242
• Bahrain 973
• Belarus 375
• Belgium 32
• Belize 501
• Benin 229
• Bermuda 1-441
• Bhutan 975
• Bolivia 591
• Bosnia 387
• Botswana 267
• Bouvet Island 47
• Brazil 55
• British Indian Ocean Territory 246
• British Virgin Islands 1-284
• Brunei 673
• Bulgaria 359
• Burkina Faso 226
• Burundi 257
• Cambodia 855
• Cameroon 237
• Cape Verde 238
• Caribbean Netherlands 599
• Cayman Islands 1-345
• Central African Republic 236
• Chile 56
• China 86
• Christmas Island 61
• Cocos (Keeling) Islands 61
• Colombia 57
• Comoros 269
• Congo - Brazzaville 242
• Congo - Kinshasa 243
• Cook Islands 682
• Costa Rica 506
• Croatia 385
• Cuba 53
• Cyprus 357
• Czech Republic 420
• Denmark 45
• Djibouti 253
• Dominica 1-767
• Egypt 20
• Equatorial Guinea 240
• Eritrea 291
• Estonia 372
• Ethiopia 251
• Falkland Islands 500
• Faroe Islands 298
• Fiji 679
• Finland 358
• France 33
• French Guiana 594
• French Polynesia 689
• French Southern Territories 262
• Gabon 241
• Gambia 220
• Georgia 995
• Germany 49
• Ghana 233
• Gibraltar 350
• Greece 30
• Greenland 299
• Guam 1-671
• Guatemala 502
• Guernsey 44
• Guinea 224
• Guinea-Bissau 245
• Guyana 592
• Haiti 509
• Heard & McDonald Islands 672
• Honduras 504
• Hong Kong 852
• Hungary 36
• Iceland 354
• India 91
• Indonesia 62
• Iran 98
• Iraq 964
• Ireland 353
• Isle of Man 44
• Israel 972
• Italy 39
• Jamaica 1-876
• Japan 81
• Jersey 44
• Jordan 962
• Kazakhstan 7
• Kenya 254
• Kiribati 686
• Kuwait 965
• Kyrgyzstan 996
• Laos 856
• Latvia 371
• Lebanon 961
• Lesotho 266
• Liberia 231
• Libya 218
• Liechtenstein 423
• Lithuania 370
• Luxembourg 352
• Macau 853
• Macedonia 389
• Malawi 265
• Malaysia 60
• Maldives 960
• Mali 223
• Malta 356
• Marshall Islands 692
• Martinique 596
• Mauritania 222
• Mauritius 230
• Mayotte 262
• Mexico 52
• Micronesia 691
• Moldova 373
• Monaco 377
• Mongolia 976
• Montenegro 382
• Montserrat 1-664
• Morocco 212
• Mozambique 258
• Myanmar 95
• Namibia 264
• Nauru 674
• Nepal 977
• Netherlands 31
• New Caledonia 687
• New Zealand 64
• Nicaragua 505
• Niger 227
• Nigeria 234
• Niue 683
• Norfolk Island 672
• North Korea 850
• Northern Mariana Islands 1-670
• Norway 47
• Oman 968
• Pakistan 92
• Palau 680
• Palestine 970
• Panama 507
• Papua New Guinea 675
• Paraguay 595
• Peru 51
• Philippines 63
• Pitcairn Islands 870
• Poland 48
• Portugal 351
• Puerto Rico 1
• Qatar 974
• Romania 40
• Russia 7
• Rwanda 250
• Samoa 685
• San Marino 378
• Saudi Arabia 966
• Senegal 221
• Serbia 381 p
• Seychelles 248
• Sierra Leone 232
• Singapore 65
• Slovakia 421
• Slovenia 386
• Solomon Islands 677
• Somalia 252
• South Africa 27
• South Georgia & South Sandwich Islands 500
• South Korea 82
• South Sudan 211
• Spain 34
• Sri Lanka 94
• Sudan 249
• Suriname 597
• Svalbard & Jan Mayen 47
• Swaziland 268
• Sweden 46
• Switzerland 41
• Syria 963
• Sao Tome and Principe 239
• Taiwan 886
• Tajikistan 992
• Tanzania 255
• Thailand 66
• Timor-Leste 670
• Togo 228
• Tokelau 690
• Tonga 676
• Tunisia 216
• Turkey 90
• Turkmenistan 993
• Turks & Caicos Islands 1-649
• Tuvalu 688
• U.S. Outlying Islands
• U.S. Virgin Islands 1-340
• UK 44
• US 1
• Uganda 256
• Ukraine 380
• United Arab Emirates 971
• Uruguay 598
• Uzbekistan 998
• Vanuatu 678
• Vatican City 39-06
• Venezuela 58
• Vietnam 84
• Wallis & Futuna 681
• Western Sahara 212
• Yemen 967
• Zambia 260
• Zimbabwe 263
• Less Than 6 Years
• 6 To 10 Years
• 11 To 16 Years
• Greater Than 16 Years

### Derivation of Volume of Cone Formula

To derive the formula for the volume of a cone let’s consider a cylinder of radius $r$ and height $h$.

Now let us locate the centre of the base $O$. From this centre measure a distance to any point on the circumference on the top. This is the slant height of the cone.

Further, let the circumference of the cylinder be $x$. Now draw a circle with slant height as radius and mark an arc of length $x$. Draw a sector $AOB$ with $L$ as radius and the length of the arc as $x$. And after that cut this sector.

Finally, let’s make cones with this sector. This right circular cylinder and a right circular cone are of the same base radius and the same height.

Fill this cone with sand up to the brim. Pour it into the cylinder.

Is it filled? No. Repeat it.

Now is it filled? No, so pour once more.

Now, the tin is completely filled. So it takes $3$ sand-filled cones to completely fill a $1$ cylinder.

From this observation, we come to the conclusion that three times the volume of a cone, makes up the volume of a cylinder, which has the same base radius and the same height as the cone, which means that the volume of the cone is one-third the volume of the cylinder.

So, the volume of a cone = $\frac {1}{3} \pi r^{2} h$, where $r$ is the base radius and $h$ is the height of the cone.

### Volume of a Cone Examples

Ex 1: Find the volume of a cone of base radius $3.5 in$ and height $12 in$.

The radius of the base of cone $r = 3.5 in$

Height of the cone $h = 12 in$

Volume of cone = $\frac {1}{3} \pi r^{2} h = \frac {1}{3} \times \frac {22}{7} \times 3.5^{2} \times 12 = 154 in^{3}$.

Ex 2: Amount of liquid in a conical flask of base radius $10.5 cm$ is $924 c.c.$. Find the level of water in the flask.

The radius of the base of a conical flask $r = 10.5 cm$

The volume of water in the conical flask $V = 924 c.c. = 924 cm^{3}$

Let the height of the water level in the flask be $h$ cm.

Therefore, $924 = \frac {1}{3} \times \frac{22}{7} \times 10.5^{2} \times h => h = 8 cm$.

Ex 3: If the radius of a cone is doubled and height is halved, then find the ratio of the new volume to the original volume of the cone.

Let the radius of the base of a cone be $r$ and its height is $h$.

Radius is doubled, therefore, a new radius of the cone = $2r$.

Height is halved, therefore, new height of the cone = $\frac {h}{2}$.

Volume of the original cone =$\frac {1}{3} \pi r^{2}h$.

Volume of the new cone =$\frac {1}{3} \pi \left(2r \right)^{2}\left(\frac {h}{2} \right) = \frac {1}{3} \pi \left(2r^{2}h \right)$.

Therefore, the ratio of new volume to the original volume = $\frac{\frac {1}{3} \pi \left(2r^{2}h \right)}{\frac {1}{3} \pi r^{2}h} = 2:1$.

## Cone – A 3D Solid Shape

A cone is a shape formed by using a set of line segments or lines which connects a common point, called the apex or vertex, to all the points of a circular base(which does not contain the apex). The distance from the cone’s vertex to the base is the height of the cone.

The circular base has a measured value of radius. And the length of the cone from apex to any point on the circumference of the base is the slant height. Based on these quantities, there are formulas derived for the surface area and volume of the cone. In the figure you will see, the cone is defined by its height, the radius of its base, and slant height.

## Types of Cone

The cones are broadly divided into two categories.

### Right Circular Cone

A cone that has a circular base and the axis from the vertex of the cone towards the base passes through the center of the circular base. The vertex of the cone lies just above the center of the circular base. The word “right” is used here because the axis forms a right angle with the base of the cone or is perpendicular to the base.

These are the most common types of cones that are used in geometry. See the figure below which is an example of a right circular cone.

### Oblique Cone

A cone that has a circular base but the axis of the cone is not perpendicular to the base, is called an Oblique cone. The vertex of this cone is not located directly above the centre of the circular base. Therefore, this cone looks like a slanted cone or tilted cone.

### Right Circular Cone

A right circular cone is one whose axis is perpendicular to the plane of the base. We can generate a right cone by revolving a right triangle about one of its legs.

In the figure, you can see a right circular cone, which has a circular base of radius $r$ and whose axis is perpendicular to the base. The line which connects the vertex of the cone to the centre of the base is the height of the cone. The length at the outer edge of the cone, which connects a vertex to the end of the circular base is the slant height.

## Relation Between Radius, Height, and Slant Height of a Right Circular Cone

Since, the radius, height, and slant height of a right circular cone form a right triangle, therefore these three are related to each other by a Pythagoras theorem, where slant height is the hypotenuse and the radius and height are the two legs of the right triangle.

Therefore, according to the Pythagoras theorem, $l^{2} = r^{2} + h^{2} => l = \sqrt{r^{2} + h^{2}}$

Similarly, $r = \sqrt{l^{2} – h^{2}}$ and $h = \sqrt{l^{2} – r^{2}}$

where $r$ is the radius, $h$ is the height and $l$ is the slant height of a cone.

## Conclusion

The volume of a cone is the number of cubic units, occupied by it completely and is calculated by using its radius and height. If $r$ is the radius and $h$ is the height of a cone, then the formula for computing its volume is $\frac {1}{3} \pi r^{2} h$.

## Practice Problems

1. Find the volume of the cone if the height and the slant height of a cone are $18 cm$ and $21 cm$, respectively.
2. If the radius is $3.5 cm$ and the height is $12 cm$ find the volume of the cone.
3. The radius and slant height of a cone is $20 cm$ and $29 cm$ respectively. Find its volume.
4. The height of a cone is $21 cm$. If its volume is $1500 cm^{3}$, find the radius of the base.
5. If the volume of a cone is $1500 cm^{3}$ and the radius of the base is $7 cm$, find the slant height of the cone.
6. The circumference of the base of a $12 m$ high wooden solid cone is $44 m$. Find the volume.
7. If the volume of a cone is $48 \pi cm^{3}$ and the height is $10 cm$, find the radius of its base.

## FAQs

### What is the volume of a cone?

The volume of a cone is the amount of space in it. It can be obtained by multiplying one-third of its base area by its height. The volume of a cone of base radius $r$ and height $h$’ is $\frac {1}{3} \pi r^{2}h$.

### How do you find the volume of a cone?

The formula used to find the volume of a cone of base radius $r$ and height $h$ is $\frac {1}{3} \pi r^{2} h$.

### What is the volume of a cone using diameter?

Let us consider a cone of radius $r$, diameter $d$, and height $h$. The volume of a cone of base radius $r$ and height $h$ is $V = \frac {1}{3} \pi r^{2}h$.
We also know that $r = \frac {d}{2}$.
By substituting this in the above formula we get $V = \frac {1}{3} \pi \frac {d^{2}h}{4}$.


text:
{{ item.displayTitle }}
navigate_next
No history yet!
Progress & Statistics equalizer Progress expand_more
Student
navigate_next
Teacher
navigate_next
{{ filterOption.label }}
{{ item.displayTitle }}
{{ item.subject.displayTitle }}
arrow_forward
When a bank lends money they charge a fee called the simple interest. The interest is based on a ratio of the loan. This percentage indicates the amount of money that should be paid to the bank each year. If the interest rate is $3\, \%$ on a $1000$ dollar loan, it costs $0.03\cdot 1000=30 \text{ USD}$ each year until the loan is paid. There is a difference in interest rate and interest cost. The interest rate is the percentage of the loan that should be paid, in this case, $3\,\%.$ Unlike the interest cost, that is the actual sum that has to be paid in interest each year, for this loan it's $30$ USD.


text:
# Axiomatizing EL^_gfp-General Concept Inclusions in the Presence of Untrusted Individuals

##### Daniel BorchmannDaniel Borchmann
Daniel Borchmann
Axiomatizing EL^_gfp-General Concept Inclusions in the Presence of Untrusted Individuals
Proceedings of the 26th International Workshop on Description Logics (DL-2013), volume 1014 of CEUR Workshop Proceedings, 65-79, July 2013. CEUR-WS.org
• KurzfassungAbstract
To extract terminological knowledge from data, Baader and Distel have proposed an effective method that allows for the extraction of a base of all valid general concept inclusions of a given finite interpretation. In previous works, to be able to handle small amounts of errors in our data, we have extended this approach to also extract general concept inclusions which are almost valid in the interpretation. This has been done by demanding that general concept inclusions which are almost valid are those having only an allowed percentage of counterexamples in the interpretation. In this work, we shall further extend our previous work to allow the interpretation to contain both trusted and untrusted individuals, i.e. individuals from which we know and do not know that they are correct, respectively. The problem we then want to solve is to find a compact representation of all terminological knowledge that is valid for all trusted individuals and is almost valid for all others.
• Forschungsgruppe:Research Group: Automatentheorie
@inproceedings{ Borc-DL13,
author = {Daniel {Borchmann}},
booktitle = {Proceedings of the 26th International Workshop on Description Logics ({DL-2013})},
month = {July},
pages = {65--79},
publisher = {CEUR-WS.org},
series = {CEUR Workshop Proceedings},
title = {Axiomatizing $\mathcal{E\!L}^{\bot}_{\mathrm{gfp}}$-General Concept Inclusions in the Presence of Untrusted Individuals},
venue = {Ulm, Germany},
volume = {1014},
year = {2013},
}


text:
# Interior angles of a Triangle

An angle that is formed inside a triangle by the intersection of its sides, is called an interior angle of a triangle.

## Introduction

A triangle is formed by connecting the endpoints of three line segments as a closed geometric shape. The intersection of every two sides of a triangle forms an angle internally. Hence, the angle is called an interior angle of triangle. It is also called as an internal angle of a triangle.

In a triangle, the three line segments are intersected at three locations on a plane. Hence, three interior or internal angles are formed inside a triangle.

### Example

For understanding the concept of internal angles of a triangle, let’s construct a triangle geometrically.

1. Take three line segments of any length.
2. Form a closed geometric shape by connecting an endpoint of a line segment to an endpoint of another line segment. Thus, a triangle is formed geometrically.
3. The connection of every two line segments inside a triangle forms an angle. The angle is called an interior or internal angle. There are three interior angles formed in a triangle.

Thus, a triangle, denoted by $\Delta MLN$ is formed geometrically.

In this triangle, $\angle LMN$, $\angle MLN$ and $LNM$ are called interior or internal angles of the triangle.

In this example, the internal angles $\angle LMN$, $\angle MLN$ and $LNM$ are unknown but they can be measured by a protractor.

The interior angles in $\Delta MLN$ are measured that

$(1).\,\,\,$ $LMN \,=\, 42^°$

$(2).\,\,\,$ $MLN \,=\, 56^°$

$(3).\,\,\,$ $LNM \,=\, 82^°$

Geometrically, the sum of interior angles in a triangle is equal to $180^°$.

Latest Math Problems
Email subscription
Math Doubts is a best place to learn mathematics and from basics to advanced scientific level for students, teachers and researchers. Know more
Follow us on Social Media
###### Math Problems

Learn how to solve easy to difficult mathematics problems of all topics in various methods with step by step process and also maths questions for practising.


text:
# gluonts.model.deepstate package¶

class gluonts.model.deepstate.DeepStateEstimator(freq: str, prediction_length: int, cardinality: List[int], add_trend: bool = False, past_length: Optional[int] = None, num_periods_to_train: int = 4, trainer: gluonts.trainer._base.Trainer = gluonts.trainer._base.Trainer(batch_size=32, clip_gradient=10.0, ctx=None, epochs=100, hybridize=False, init="xavier", learning_rate=0.001, learning_rate_decay_factor=0.5, minimum_learning_rate=5e-05, num_batches_per_epoch=50, patience=10, weight_decay=1e-08), num_layers: int = 2, num_cells: int = 40, cell_type: str = 'lstm', num_parallel_samples: int = 100, dropout_rate: float = 0.1, use_feat_dynamic_real: bool = False, use_feat_static_cat: bool = True, embedding_dimension: Optional[List[int]] = None, issm: Optional[gluonts.model.deepstate.issm.ISSM] = None, scaling: bool = True, time_features: Optional[List[gluonts.time_feature._base.TimeFeature]] = None, noise_std_bounds: gluonts.distribution.lds.ParameterBounds = gluonts.distribution.lds.ParameterBounds(lower=1e-06, upper=1.0), prior_cov_bounds: gluonts.distribution.lds.ParameterBounds = gluonts.distribution.lds.ParameterBounds(lower=1e-06, upper=1.0), innovation_bounds: gluonts.distribution.lds.ParameterBounds = gluonts.distribution.lds.ParameterBounds(lower=1e-06, upper=0.01))[source]

Construct a DeepState estimator.

This implements the deep state space model described in [RSG+18].

Parameters
• freq – Frequency of the data to train on and predict

• prediction_length – Length of the prediction horizon

• cardinality – Number of values of each categorical feature. This must be set by default unless use_feat_static_cat is set to False explicitly (which is NOT recommended).

• add_trend – Flag to indicate whether to include trend component in the state space model

• past_length – This is the length of the training time series; i.e., number of steps to unroll the RNN for before computing predictions. Set this to (at most) the length of the shortest time series in the dataset. (default: None, in which case the training length is set such that at least num_seasons_to_train seasons are included in the training. See num_seasons_to_train)

• num_periods_to_train – (Used only when past_length is not set) Number of periods to include in the training time series. (default: 4) Here period corresponds to the longest cycle one can expect given the granularity of the time series. See: https://stats.stackexchange.com/questions/120806/frequency -value-for-seconds-minutes-intervals-data-in-r

• trainer – Trainer object to be used (default: Trainer())

• num_layers – Number of RNN layers (default: 2)

• num_cells – Number of RNN cells for each layer (default: 40)

• cell_type – Type of recurrent cells to use (available: ‘lstm’ or ‘gru’; default: ‘lstm’)

• num_parallel_samples – Number of evaluation samples per time series to increase parallelism during inference. This is a model optimization that does not affect the accuracy ( default: 100).

• dropout_rate – Dropout regularization parameter (default: 0.1)

• use_feat_dynamic_real – Whether to use the feat_dynamic_real field from the data (default: False)

• use_feat_static_cat – Whether to use the feat_static_cat field from the data (default: True)

• embedding_dimension – Dimension of the embeddings for categorical features (default: [min(50, (cat+1)//2) for cat in cardinality])

• scaling – Whether to automatically scale the target values (default: true)

• time_features – Time features to use as inputs of the RNN (default: None, in which case these are automatically determined based on freq)

• noise_std_bounds – Lower and upper bounds for the standard deviation of the observation noise

• prior_cov_bounds – Lower and upper bounds for the diagonal of the prior covariance matrix

• innovation_bounds – Lower and upper bounds for the standard deviation of the observation noise

create_predictor(transformation: gluonts.transform._base.Transformation, trained_network: mxnet.gluon.block.HybridBlock) → gluonts.model.predictor.Predictor[source]

Create and return a predictor object.

Returns

A predictor wrapping a HybridBlock used for inference.

Return type

Predictor

create_training_network() → gluonts.model.deepstate._network.DeepStateTrainingNetwork[source]

Create and return the network used for training (i.e., computing the loss).

Returns

The network that computes the loss given input data.

Return type

HybridBlock

create_transformation() → gluonts.transform._base.Transformation[source]

Create and return the transformation needed for training and inference.

Returns

The transformation that will be applied entry-wise to datasets, at training and inference time.

Return type

Transformation

freq = None
lead_time = None
prediction_length = None


text:
Don't confuse brain with a bull market. - Humphrey B Neill
•   Get new articles and videos in your inbox.
•   Get exclusive notification of new deals and discounts.
•   Email is the best way to stay connected.
•   You can always unsubscribe using the links at the bottom of any email or at the bottom of this website.
•   Your information will never be shared with or sold to a 3rd party.

# What is Profit Factor?

Profit factor is one of many different types of metrics used to assess a trading strategy.

It's definition is quite simple. It's the ratio of gross profit over gross loss.

$PF = \frac{GP}{GL}$

where

• $$PF$$ is profit factor
• $$GP$$ is gross profit
• $$GL$$ is gross loss

Let's break this down.

Watch the Video

## What is Gross Profit?

Gross profit is the sum of the gain of all winning trades. We can write this as follows:

$GP = \sum_{t=1}^{N} P_t$

where

• $$GP$$ is gross profit
• $$t$$ represents each successive round-trip winning trade
• $$N$$ is the total number of winning trades
• $$P_t$$ is the net profit of each winning trade, which will be positive because we're only looking at winners

If you're not familiar with the summation ( $$\sum$$ ) symbol it just means sum. Let's expand it:

$GP = P_1 + P_2 + P_3 + ... + P_N$

The gross profit will always be a positive value because it's always a sum of positive gains.

## What is Gross Loss?

Gross loss is the sum of the losses of all losing trades. We can write this as follows:

$GL = \sum_{t=1}^{N} L_t$

where in this case

• $$GL$$ is gross loss
• $$t$$ represents each successive round-trip losing trade
• $$N$$ is the total number of losing trades
• $$L_t$$ is the loss of each losing trade

Note that the trade loss, $$L_t$$, is a positive number meaning that gross loss will also be positive because we're only dealing with losers now.

Since gross profit and gross loss are both positive numbers, profit factor is also a positive number.

Why would we make gross loss a positive number instead of a negative one?

Imagine you're looking at a trade and you ask, "What's the net profit?" If the trade made money you expect a response like, "The net profit is $40." You don't normally say, "Positive$40," but that's what you mean.

But what if the trade lost money, how do you answer the question. "What is the net profit?" You'd say something like, "It lost $40." You say lost to indicate a value in the negative direction. If you could only report it as a single number, you'd say "Minus$40."

Now let's switch it up and ask the question, "What is the loss on this trade?" If it didn't lose, well, you might say, "Actually, it wasn't a loss, it gained $40." But you have to say all those extra words to mean that it performed opposite to the question. A profit is in the opposite direction of a loss, therefore it's a negative loss of minus$40. If a trade gains $40 and you're asking, "What's the loss?" and you can only give one number in reply, the answer is, "-$40."

And that's why we report a loss as positive. Loss means down, negative, unfavorable, etc. So, yes, if the trade lost money, then it's in that same direction as the word loss. It's in agreement with the word loss. So, we say the loss is a positive $40 and if the trade made money then we say the loss is negative$40.

Clear as mud?

You may think I'm belaboring the point, but a minus sign in the wrong place can ruin your whole day.

## What is Profit Factor Good For?

Let's understand profit factor by looking at it's extremes.

What happens when all of our trades are losers?

In this case, gross profit is zero and gross loss is some positive value. Our profit factor is therefore zero.

What happens when all of our trades are winners?

Well, that means we have no losers so the gross loss would be zero. Because it's on the bottom of the fraction, the profit factor is infinity ( $$\infty$$ ).

We know from this, therefore, that profit factor is always a value between zero and infinity.

Now, what happens if we lose exactly as much as we profit? In this case the ratio is exactly one. This would be a breakeven strategy.

If profit factor is less than 1.0, then the strategy is a loser. If greater than 1.0 the strategy is making at least a little profit.

So, is a profit factor of 10 better still? That would mean our strategy earns ten times more than it loses.

In theory, this would be great, the higher the better. But in practice I'm not so sure you'll see a profit factor of ten. I'd certainly take a second look at my calculations.

Rules of thumb seem to be this:

• Kevin Davey says values over 1.0, meaning they are breakeven or better, may have some merit, but that values less than 1.5 will likely be challenging.
• Others say that by the time you get up to values of 2.2 that you may already be over-optimizing.

Looks like the sweet spot for profit factor is about 1.5 to 2.5.

If you get higher values, that's great, just be sure to double check your numbers.

## What Profit Factor Isn't Good For

Profit factor does not compare the number of winning trades to the number of losers.

You could have a backtest with 51 trades in which one was a winner and 50 were losers and you could still have a nice profit factor.

For example, suppose your average loss is $10 and your one win is$1000. That's a profit factor of

$PF = \frac{1 \times 1000}{50 \times 10} = 2.0$

That's a good profit factor, but clearly you wouldn't want to trade this system.

Version: 6.0.20200920.1535


text:
How does Hubble Law relate distance to velocity?

Feb 10, 2016

They are proportional, at least for nearby objects.

Explanation:

Originally Hubble discovered for the near galaxies that the further they are, the quicker they are receding from us.
$v = H \cdot d$


text:
Article

# Two estimators of the long-run variance: Beyond short memory

Imperial College Business School, Imperial College London, London SW7 2AZ, UK
01/2009; DOI: 10.1016/j.jeconom.2009.02.010
Source: RePEc

ABSTRACT This paper deals with the estimation of the long-run variance of a stationary sequence. We extend the usual Bartlett-kernel heteroskedasticity and autocorrelation consistent (HAC) estimator to deal with long memory and antipersistence. We then derive asymptotic expansions for this estimator and the memory and autocorrelation consistent (MAC) estimator introduced by Robinson [Robinson, P. M., 2005. Robust covariance matrix estimation: HAC estimates with long memory/antipersistence correction. Econometric Theory 21, 171–180]. We offer a theoretical explanation for the sensitivity of HAC to the bandwidth choice, a feature which has been observed in the special case of short memory. Using these analytical results, we determine the MSE-optimal bandwidth rates for each estimator. We analyze by simulations the finite-sample performance of HAC and MAC estimators, and the coverage probabilities for the studentized sample mean, giving practical recommendations for the choice of bandwidths.

### Full-text

Available from: Karim M. Abadir, Dec 26, 2013
0 Followers
·
88 Views
• Source
##### Article: A goodness-of-fit test for marginal distribution of linear random fields with long memory
[Hide abstract]
ABSTRACT: This paper addresses the problem of fitting a known distribution function to the marginal distribution of a stationary long memory moving average random field observed on increasing $$\nu$$-dimensional “cubic” domains when its mean $$\mu$$ and scale $$\sigma$$ are known or unknown. Using two suitable estimators of $$\mu$$ and a classical estimate of $$\sigma$$, a modification of the Kolmogorov-Smirnov statistic is defined based on the residual empirical process and having a Cauchy-type limit distribution, independent of $$\mu ,\sigma$$ and the long memory parameter d. Based on this result, a simple goodness-of-fit test for the marginal distribution is constructed, which does not require the estimation of d or any other underlying nuisance parameters. The result is new even for the case of time series, i.e., when $$\nu =1$$. Findings of a simulation study investigating the finite sample behavior of size and power of the proposed test is also included in this paper.
Metrika 01/2015; DOI:10.1007/s00184-015-0550-z · 0.45 Impact Factor
• Source
##### Article: A two-sample test for comparison of long memory parameters
[Hide abstract]
ABSTRACT: We construct a two-sample test for comparison of long memory parameters based on ratios of two rescaled variance (V/S) statistics studied in Giraitis et al. [L. Giraitis, R. Leipus, A. Philippe, A test for stationarity versus trends and unit roots for a wide class of dependent errors, Econometric Theory 21 (2006) 989–1029]. The two samples have the same length and can be mutually independent or dependent. In the latter case, the test statistic is modified to make it asymptotically free of the long-run correlation coefficient between the samples. To diminish the sensitivity of the test on the choice of the bandwidth parameter, an adaptive formula for the bandwidth parameter is derived using the asymptotic expansion in Abadir et al. [K. Abadir, W. Distaso, L. Giraitis, Two estimators of the long-run variance: beyond short memory, Journal of Econometrics 150 (2009) 56–70]. A simulation study shows that the above choice of bandwidth leads to a good size of our comparison test for most values of fractional and ARMA parameters of the simulated series.
Journal of Multivariate Analysis 10/2010; 101(9-101):2118-2136. DOI:10.1016/j.jmva.2010.04.003 · 0.94 Impact Factor
• Source
##### Article: A two-sample test for comparison of long memory parameters
Journal of Multivariate Analysis 01/2010; 101(9):2118-2136. · 0.94 Impact Factor


text:
• # question_answer The correct order of the mobility of the alkali metal ions in aqueous solution is A)  $L{{i}^{+}}>N{{a}^{+}}>{{K}^{+}}>R{{b}^{+}}$ B)  $N{{a}^{+}}>{{K}^{+}}>R{{b}^{+}}>L{{i}^{+}}$ C)  ${{K}^{+}}>R{{b}^{+}}>N{{a}^{+}}>L{{i}^{+}}$ D)  $R{{b}^{+}}>{{K}^{+}}>N{{a}^{+}}>L{{i}^{+}}$

The correct order of hydration energy of the alkali metal ions in aqueous solutions is $L{{i}^{+}}>N{{a}^{+}}>{{K}^{+}}>R{{b}^{+}}$and due to hydration of ion, mobility decreases. Thus, the correct order of the mobility of these ions is $R{{b}^{+}}>{{K}^{+}}>N{{a}^{+}}>Li$


text:
# Huawei E220 Modem on Linux

Unfortunately for mobile broadband Internet connections, network setups are usually difficult and inconsistent experiences between the different network providers. Getting the modem to work can be a rather frustrating experience if things don’t work straight out of the box.

Before I start, I’ll let you know that some of the settings here may be specific only to my provider, O2 Ireland, which you may have to do your own specific tweaks, and as the saying goes, “your mileage may vary”.

On the good side, the Huawei E220 modem seems to be a rather popular and well supported device, and it did on one instance worked straight out of the box on one of my friend’s computer running Ubuntu 9.04 with Network Manager. It doesn’t seem to work on 8.10, not on my machine (Ubuntu) or my laptop (Xubuntu), which may just boil down to configuration issues, or not. On the funny side, when I tried to get the settings off my friend’s computer by right-clicking on it, it simply froze the machine entirely. (Windows users, insert your jibes here ;p)

This problem is probably specific to O2, since I had a Vodafone modem dongle that I had borrowed before, which worked flawlessly on when plugged into my laptop, which I had assumed will be the case when I got O2, but it turned out not to be so.

Update: Found the reason why Network Manager will work in 9.04 but not 8.10, the newer release had included Modem Manager which had specific setup that will request for a PIN which the O2 card was set up in default. By comparison, the Vodafone dongle did not require a PIN, hence network manager worked without a hitch.

Anyhow, maybe these information I’ve gleaned from will help you find out what you need to get things to work.

What the lights on the modem really means.

Ignore what the documentation says (partially) that came with the subscription. From my personal observation, if the light is green and flashing, it means that the modem is active, just that it’s not authenticated to the provider. That should be a sign that your modem is working.

The modem is also capable of flashing in blue colour (which is nowhere explained in the booklet). This means that your connection is authenticated with the provider, but currently is not having ppp connection established.

If the lights are in solid green, blue, or light blue, it means that your connection is active, and in various different operating speeds (GPRS, 3G, HSDPA respectively) as explained in the booklet. From my observations, it seems like the connection typically reside in the 3G mode (dark blue colour) when it’s passive, and only switches to HSDPA mode whenever you start sending or receiving data from the network.

Modem doesn’t work with Network Manager

A number of sources suggests that the E220 modem works straight with Linux via Network Manager, but it certainly didn’t work for me straight off. So I had do some reading on the wireless broadband forums to try to find answers. Most of them are geared towards solving problems for Vodafone, and the information is really spotty when it comes to O2. Given that I had no idea where to look to find out what’s actually happening inside Network Manager, I had to try some other alternatives.

Update: I didn’t know where to look before, but I’ve since found that Network Manager logs to /var/log/daemon.log - still the messages are not too helpful to actually tell you what exactly is the problem.

The saviour - wvdial

‘wvdial’ is the alternative application that got the connection to work after a bit of reading. The documentation on wvdial can be confusing, and even as I’ve gotten it to work, I still don’t fully understand the relationship between wvdial and pppd. Here’s the excerpted config I had in ‘/etc/wvdial.conf’, it’s a little half-baked, and sometimes still fails:

[Dialer O2]
ISDN = 0
Baud = 460800
Modem = /dev/ttyUSB0
Phone = *99#
Modem Type = Analog Modem
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Init3 = AT+CPIN="1234"
Init5 = AT+CGDCONT=1,"IP","open.internet"

[Dialer O22]
ISDN = 0
Baud = 460800
Modem = /dev/ttyUSB0
Phone = *99#
Modem Type = Analog Modem
Stupid Mode = 1
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
#Init3 = AT+CPIN="1234"
Init5 = AT+CGDCONT=1,"IP","open.internet"

Do replace ‘1234’ with the actual PIN number that you have.

You can see that I have 2 entries for the connection, which the only difference between the two is that the second entry doesn’t have a PIN authentication command. This is the intentional, because wvdial does not know whether the modem is in authenticated mode or not (ie, whether if it’s flashing blue or flashing green. The ATZ command does not seem to reset this authenticated state.)

If you started your computer fresh and your modem is showing a flashing green light, invoke wvdial this way:

% wvdial O2

That should work if you started your modem cold. Sometimes the first connection gets dropped for no reason, and to try to reestablish the connection, run wvdial with the O22 connection instead. If you succeed, you should see an output like this:

--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
--> Sending: AT+CGDCONT=1,"IP","open.internet"
AT+CGDCONT=1,"IP","open.internet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Sat May 30 08:20:44 2009
--> Pid of pppd: 7312
--> Using interface ppp0
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c
--> pppd: H�c X�c ��c

Trying Network Manager Again

If you have established a connection successfully before, but got dropped for some reason, the light on your modem should be flashing blue. In this case your modem is in the authenticated state, and Network Manager will start working happily if you wanted to use it now.

As I said, Network Manager did work with one of my friend’s computer - the difference being that when I tried connecting, his version of Network Manager prompted me to key in my PIN, while my didn’t. Even manually setting the PIN in the configuration won’t make it work.

But at least it’ll work indirectly, and tells us that the problem lies within authentication.

Fun things to do with the modem - AT Commands

Through using wvdial, I realised that the usb modem actually uses a variant of the AT commands of the phone modems I used to have for dialups and BBSes. It kind of piqued my interest a bit, and good for reliving the good old days of fiddling around with AT commands on my modem.

To do so, we’ll need to find the interface in which you can send and receive commands to - ‘dmesg’ will be helpful for these occasions:

[   21.839161] usb-storage: device found at 2
[   21.839163] usb-storage: waiting for device to settle before scanning
[   21.849151] usbserial: USB Serial support registered for GSM modem (1-port)
[   21.849175] option 4-1:1.0: GSM modem (1-port) converter detected
[   21.849429] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB0
[   21.849441] option 4-1:1.1: GSM modem (1-port) converter detected
[   21.849519] usb 4-1: GSM modem (1-port) converter now attached to ttyUSB1
[   21.849535] usbcore: registered new interface driver option
[   21.849538] option: USB Driver for GSM modems: v0.7.2

So, /dev/ttyUSB0 is the interface in which Network Manager/wvdial uses to connect to the mobile phone provider, which kind of perplexed me why there is an additional /dev/ttyUSB1 interface. One of the things that came up from googling was an out-of-date kernel support page for the modem.

It provided a tool to read the signal strength of the modem, which out of curiosity, I downloaded the source code and waded through it. That’s when I realised that /dev/ttyUSB1 is the interface in which you can issue AT commands to.

Armed with that knowledge, we can now start issuing commands straight into the device! Relying on a primitive method, do this by starting two terminal windows side by side. On one window, do:

$cat /dev/ttyUSB1  This shows you what’s the output coming out from the commands issued. On the other window it is where you issue your commands. For example: $ echo "AT" > /dev/ttyUSB1

You should see “OK” coming out from the other window, showing that the modem has acknowledge your ‘attention’ command. Pretty cool eh?

Fun Things To Do #1: Disabling PIN Authentication

Remember the problem with PIN authentication that prevented Network Manager from working properly? Well you can side-step the problem by disabling the PIN authentication feature on the SIM card:

echo 'AT+CLCK="SC",0,"1234"' > /dev/ttyUSB1

Replace ‘1234’ with the actual PIN number that you have. This should disable the need for authentication. A word of caution: do this only if you’re not too concerned about the physical security of your modem, otherwise if it gets lost or stolen, others can start using your Internet connection for free!

Fun Things To Do #2: Get SMS Messages

For linux users, we aren’t provided with any GUI for us to access and send SMS messages from the SIM card. Unfortunately the O2 site registration assumes that we are all Windoze users, which is the only way in which we can pull out the authentication SMS message that it sends to the mobile phone.

Well fret no more, here’s how we can gain access to SMS messages simply by using AT commands:

$echo 'AT+CMGF=1' > /dev/ttyUSB1$ echo 'AT+CMGL="ALL"' > /dev/ttyUSB1

This should turn on SMS mode on the modem and dump out all the received SMSes. And from the output messages, you can pick out the authentication message that looks like this:

+CMGL: 0,"REC READ","02",,"25/05/27,20:33:07+04"

Welcome to O2 Broadband! Should you have any queries, visit www.o2.ie/broadbandfaq or our interactive forum on http://forums.o2online.ie. Best wishes, O2.


text:
GMAT Question of the Day - Daily to your Mailbox; hard ones only

 It is currently 21 Oct 2019, 13:19

### GMAT Club Daily Prep

#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

# What least number must be subtracted from 1936

Author Message
TAGS:

### Hide Tags

Senior Manager
Joined: 10 Apr 2018
Posts: 267
Location: United States (NC)
What least number must be subtracted from 1936  [#permalink]

### Show Tags

11 Apr 2019, 11:34
2
00:00

Difficulty:

35% (medium)

Question Stats:

64% (02:09) correct 36% (01:57) wrong based on 28 sessions

### HideShow timer Statistics

What least number must be subtracted from 1936 so that the remainder when divided by 9,10,15 in each case is 7.

(A) 39
(B)44
(C)51
(D)129
(E)141

_________________
Probus

~You Just Can't beat the person who never gives up~ Babe Ruth
Intern
Joined: 31 May 2018
Posts: 13
Location: India
GPA: 4
Re: What least number must be subtracted from 1936  [#permalink]

### Show Tags

11 Apr 2019, 13:36
Step I-

LCM of 9, 10, 15 = 90

Step II-

$$\frac{1936}{90}$$ = quotient (21), remainder (46)

To get 7 as a remainder:
46-x = 7
x= 39

The least number is 39 that should be subtracted from 1936.

i.e. 1936-39 = 1897

[*] $$\frac{1897}{9}$$ = quotient (210), remainder (7)

[*] $$\frac{1897}{10}$$ = quotient (189), remainder (7)

[*] $$\frac{1897}{15}$$ = quotient (126), remainder (7)

Re: What least number must be subtracted from 1936   [#permalink] 11 Apr 2019, 13:36
Display posts from previous: Sort by


text:
# lpartition_negative_binomial

function lpartition_negative_binomial(k:Integer, ρ:Real) -> Real

Log partition function of a negative binomial variate.

• k: Number of successes before the experiment is stopped.
• ρ: Probability of success.

Return: the log of the normalization constant.


text:
. for Let a function f be defined b...
Question

# . for Let a function f be defined by X = 0 and f(0) = 2. Then fis :

JEE/Engineering Exams
Maths
Solution
102
4.0 (1 ratings)
( f(x)=frac{x-|x|}{x} quad x, eq 0 quad 4 quad f(0)=2 ) At o it is discontingus 4 continous everywhere remaining ( r^{prime} )


text:
• Create Account

## C++ - Is Goto a Good Practice?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

46 replies to this topic

### #21armitroner  Members

Posted 12 November 2012 - 08:34 AM

I only used goto in one small section, since I don't have much need for it elsewhere.

You are essentially abusing goto to create a loop. Instead, use an explicit loop:
...

Note that this automatically handles the case where the user types an invalid option by looping around, though it is generally nicer to print a specific message in this case.

Another potential improvement is to dynamically remove invalid options from the menu. Something like this:
...

I'm not sure if you are familiar with std::vector or function pointers. Feel free to ask a question if you don't understand what this code is doing.

From what I can see in the second example, it's working sort of like an array. It appears to be creating a single, erm, (for lack of a better term) method that carries the other functions in it, kinda like how a class works? Then it grabs how many functions are underneath CombatChoice and displays them, dependent upon wether or not they meet the conditions given when using the push_back function. (not sure what push_back is)
Finally, when choosing the option, the reason you created that variable when creating the menu was to add an extra bumper in case the player chose the number of an option that wasn't even there.

I'll do a bit of reading on std::vector, since this is the first time I've come across the term. This was actually my first serious C++ project, so I had to hunt down tons of stuff on the net.
Anyhow, thanks for the advice, and I'll be working on improving my code once my compiler gets fixed...

### #22carangil  Members

Posted 12 November 2012 - 04:01 PM

Goto still exists for a reason. At work, we have a large C codebase that has a few goto's in it. It's used as 'goto cleanup', to bail-out of a function, but allow for freeing objects. In C++ you would use an exception or just let the destructors do their job, in C there is no such luxury. You might also be able to make a case for using it in a C++ program if you need to manually free something that doesn't have a destructor ( maybe you were interfacing to something written in plain C), but you would probably want to wrap your C structs into a C++ object with a proper destructor instead.

I do see this sometimes, and I think this construct is worse than a goto:
[source lang="C++"] do { stuff; if (!stuff) break; //really just a 'goto' in disguise stuff; if (oh_crap) break; //another goto for (i=0;xxx;xxx) { if (whatever(i)) { outer_break=true; break; } } if (outer_break) break; // well wasn't that awkward stuff;} while (0);free(things);[/source]
As you can see above, break is really just as bad as goto, and if you need to break from inside an inner loop, it gets awkward.

The other acceptable use I see for goto are the gcc extenstion of 'computed gotos' where you can have label pointers, and build a jump table. This is handy if you are writing a bytecode interpreter, BUT is really just the same thing as the jump table that a good compiler is supposed to try to make for a switch/case statement.

Other than these two cases, goto is almost always a mistake.

Posted 13 November 2012 - 07:32 AM

Obligatory XKCD.

### #24dmatter  Members

Posted 13 November 2012 - 05:52 PM

As far as I know there is no case where a goto in C++ is the best tool for the job. I have never had cause to use it in C++ and I would not be overly happy to read or maintain code that uses it either.

Goto has a couple of uses, chiefly amongst them is making loops and exiting out of nested code. Instead it's better to prefer explicit loops and factoring nested code into functions which can be exited using return.

I combination of these alternatives can be applied to your function, including some minor restructuring that makes it a little cleaner:

void Combat::combatChoice(Character&amp; C) {

if (C.health <= 0) {

cout << "----------------- You died... ------------------" << endl;

cout << "Oh dear, it seems you have died... Game Over." << endl;

return;

}

for (;;) {

cout << "----------------- Battle Options ------------------" << endl;

C.Display();

cout << "What do you want to do? \n"

<< "Type the number of the action and press enter. \n"

<< "[1] Melee Attack \n"

<< "[2] Gun Attack \n"

<< "[3] Health Potion" << endl;

short choice;

cin >> choice;

cout << "\n----------------- Battle Results ------------------" << endl;

switch (choice) {

case 1:

C.meleeAttack(M);

return;

case 2:

if(C.ammo > 0) {

C.gunAttack(M);

return;

}

cout << "You're out of ammo! \n" << endl;

break;

case 3:

if(C.potions > 0) {

C.useHP();

return;

}

cout << "You're out of potions! \n" << endl;

break;

default:

cout << "Whoops you choose an incorrect battle option, try again!\n\n";

}

}

}

So we've used an infinite loop which is basically saying "keep going till the user provides us with a workable option" (and such a thing would make a good code comment above the loop). Once a valid option has succeeded it exits from the function entirely using mid-function returns.

I find mid-function/early returns are often easier and clearer than using control variables to guide execution out of loops toward the end of a function. There are cases to be made either way.

I think rip-off's second example is better factored, more extensible and offers a superior experience for the user. An observation off the back of it is that having battle actions as member functions on a Character is slightly awkward as it involves a second abstraction for unifying the interface to them: f(C, M)
It may make sense to separate the action concept out as a first-class citizen, e.g. MeleeAttack::apply(Character & C, Monster & M);
Then just register all your Attack actions into the menu vector. You could add other member functions, such as one that predicates whether the action is even valid on the current menu (otherwise the menu code has to know something about what each attack requires).

Edited by dmatter, 13 November 2012 - 05:57 PM.

### #25Vilem Otte  GDNet+

Posted 13 November 2012 - 07:50 PM

I actually used goto once or twice in C to decrease number of nested loops in code (it made code look a bit better)... I could've used function there though, but I didn't want (separating that code would be a hell for anyone who would read it).

Basically if you are beginner (and assuming that, because this is in forums For Begginers), you shouldn't use it at all.

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

### #26Khatharr  Members

Posted 13 November 2012 - 10:23 PM

goto is not evil in and of itself. There are some very rare occasions when a carefully placed goto can save you a lot of time.

The problem is that goto is essentially an intrinsic for the 'jmp' instruction. If you're good with assembly and understand stack frames and the general behavior of the compiler then you can get away with it, but otherwise just do whatever you have to do to avoid it. The risk of unexpectedly dragging invalid state into somewhere that it doesn't belong (and not having the correct state established for that location) is simply too great.

Even if you do have a perfect grasp of the mechanics and implement a correct use of goto then you'll probably only do it either as a temporary measure or else as some form of bizarre optimization accompanied by 3 pages of commenting.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #27Aliii  Members

Posted 14 November 2012 - 06:10 AM

If goto would be that bad it wouldnt exist. Its better not to use it for jumping through long code though .....especially if many people are working on the same code.
+(Ive worked at 2 big companies ....neither allowed to use goto:))

### #28rnlf  Members

Posted 14 November 2012 - 10:08 AM

Aliii: Some things exist as an evil legacy from the dark times.

### #29SiCrane  Moderators

Posted 14 November 2012 - 10:59 AM

As far as I know there is no case where a goto in C++ is the best tool for the job.

The only thing I can think of is for the output of automatic code generators such as lexers and parsers. It produces unmaintainable spaghetti code, but it doesn't matter because it's not meant to be maintained by human hands.

### #30yoni0505  Members

Posted 14 November 2012 - 01:28 PM

Basically there's no reason to use "goto" unless your code's workflow is incorrect.

### #31Aliii  Members

Posted 14 November 2012 - 02:04 PM

Aliii: Some things exist as an evil legacy from the dark times.

I know that. But theres no "dark times" here ....many people are just allergic to goto I think:)

Posted 14 November 2012 - 02:18 PM

Aliii: Some things exist as an evil legacy from the dark times.

I know that. But theres no "dark times" here ....many people are just allergic to goto I think:)

People don't just avoid code mechanisms without a reason, in my experience there's always a better and cleaner way to solve a problem than by using goto.
And there are definitely "dark ages", C and C++ have been around for quite a while now, and both languages have evolved a lot, so it's only natural that there are features in both which have somewhat of a legacy.

I gets all your texture budgets!

### #33Orangeatang  Members

Posted 14 November 2012 - 03:20 PM

I think you've probably got your answer by now, but just to give my two cents - the use of GOTO in C++ can completely undermine the object oriented design of the language, which is after all the whole point.

### #34Aliii  Members

Posted 14 November 2012 - 04:07 PM

Aliii: Some things exist as an evil legacy from the dark times.

I know that. But theres no "dark times" here ....many people are just allergic to goto I think:)

People don't just avoid code mechanisms without a reason, in my experience there's always a better and cleaner way to solve a problem than by using goto.
And there are definitely "dark ages", C and C++ have been around for quite a while now, and both languages have evolved a lot, so it's only natural that there are features in both which have somewhat of a legacy.

It always worked fine for me. I wonder how many of those people who blame it actually used it and had all those horrible things happen to them ...and to their code. (Maybe no one:)

Of course dont use it when working in a team, dont use it in functions that are more than lets say 60 lines, ....and dont combine it with lots of break, continue, recursion and function pointers.

Posted 14 November 2012 - 04:47 PM

*snip*

It's already a warning sign if you have to make a list of some quite common and maybe essential language features you shouldn't use together with goto, just saying.

Here's another one for the list:
Using goto statements can make it really damn hard to prove the correctness of your program since it completely allows you to break your program's structure. Not being able to prove that your program works as it's supposed to will send you straight to debugging hell, and that's one place you really don't want to be.

Maybe using lots of goto statements works for you, but I can think of hundreds of designs which would also work but which would be horrible to maintain, extend and debug. We don't advise against using goto because we have some sort of weird prejudice against it, we advise against it because when it comes to C++ in almost all the cases there's a better and cleaner tool for the job.

And no I'm going to stop, I'm starting to ramble...

I gets all your texture budgets!

### #36Aliii  Members

Posted 14 November 2012 - 06:38 PM

"It's already a warning sign if you have to make a list of some quite common and maybe essential language features you shouldn't use together with goto, just saying."
....it was not a Dont-use-this-with-goto-Bible and I didnt have to make it:) ....I just gave some examples.(I think they are quite accurate though.) Plus I used the words "lots of" but nevermind

"Maybe using lots of goto statements works for you"
It doesnt, because I dont use lots of goto.

I dont wanna argue, Ive just told my experiences with goto. You almost seem like atacking me for it.

### #37Khatharr  Members

Posted 14 November 2012 - 06:59 PM

It seems like people are mostly agreeing that goto should be avoided whenever possible and the program structure questioned otherwise.

Hopefully we don't need another 'little scene'. (Though I have to admit they can be pretty amusing.)
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #38~  Members

Posted 14 November 2012 - 10:29 PM

As long as a language has goto, it isn't intrinsically bad to use it.

It is possible to use it either in a right or in a wrong way.

The thing is that as a language has a higher level than others, it is in general spontaneously easier and natural to avoid using goto.

__________________________________________________
__________________________________________________
__________________________________________________
I am currently mainly an x86 Assembly language programmer but I can program a bit of C, Pascal, and a good amount of JavaScript and PHP, so I can tell you that in languages higher than Assembly (including C) I rarely use goto. It might seem paradoxical but Assembly language has helped me no end to find ways to program very elegantly and concisely without using goto, or excessive nested ifs or nested function calls.

Now, I find myself all the time converting higher-level code to Assembly by hand. In that case, you can see that down to the bare metal level all of your loops, conditional code and the like, must be converted to conditional Assembly instructions that work exactly like goto, and in general it can't be avoided at that point (which by the way is by no means an obsolete environment but just the very essence of a machine).

I also find myself converting Assembly code to higher-level code, and in this case I must find ways to do it efficiently. I almost never need to use goto when doing this.

In other words, knowing how to use goto properly is necessary, not to be abused and not to be ignored either (specially if you know and want to use Assembly language, among other things, to work a little bit in designing or understanding compiler-like programs that generate Assembly code).

If you use it too much in a high-level language, chances are that you are still in a very incipient level of knowledge for a proper implementation of your logic when you could use syntax elements better suited for what you want to achieve in that language (e.g., using goto for no special reason when you could have used a while loop that maybe you just didn't know how to use).

### #39Khatharr  Members

Posted 15 November 2012 - 12:09 AM

It might seem paradoxical but Assembly language has helped me no end to find ways to program very elegantly and concisely without using goto, or excessive nested ifs or nested function calls.

I've also noticed this in my own coding. I think part of it is the inversion of the logic with conditional jumps. Somehow just doing a little bit of work with that subconsciously reorganized my brain and now my loops and conditionals come out smoother. It's strange that the inversion is unintuitive but somehow results in a better 'natural flow' once it's understood.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #40joshLangley  Members

Posted 15 November 2012 - 03:18 AM

Only skimmed through the topic,

In a game menu scenario I would go with a finite state machine of game states and loop through it accordingly.
kind regards,Josh Langley.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


text:
ihavemathquestions Group Title Determine whether y varies directly with x. If so, find the constant of variation k. 3y = –7x – 18 one year ago one year ago

1. ihavemathquestions Group Title

2. ihavemathquestions Group Title

@agent0smith

3. agent0smith Group Title

For the constant of variation, we need it to look like y = kx. Let's divide both sides of 3y = –7x – 18 by 3, to get $y = -\frac{7 }{ 3 }x –\frac{ 18 }{3 }$ Try comparing $y= kx$to$y = -\frac{7 }{ 3 }x –\frac{ 18 }{3 }$

4. ihavemathquestions Group Title

5. ihavemathquestions Group Title

@agent0smith

6. agent0smith Group Title

But notice that we have$y = -\frac{7 }{ 3 }x –\frac{ 18 }{3 }$ Does it look like y=kx? or y=kx minus 18/3?

7. ihavemathquestions Group Title

no they don't so its D

8. agent0smith Group Title

For constant of variation, you only want y = kx, not y = kx plus or minus some number.

9. ihavemathquestions Group Title

so there is no constant of variation its no

10. agent0smith Group Title

Correct :) *If* it was just $y = -\frac{7 }{ 3 }x$ then it would be in the form y = kx.

11. ihavemathquestions Group Title

thanks baby xo

12. agent0smith Group Title

haha no prob :)


text:
# Petronas Selenia WR Pure Energy 5W-30

#### DESCRIPTION

Selenia WR Pure Energy is a newly conceived fully synthetic lubricant capable of answering the needs of the most modern diesel engines. Passing the ACEA C2 specification certifies the low ash content, which is an indispensable characteristic to protect the particulate filter from residual combustion products that could cause dangerous clogging of the filter itself.

#### CHARACTERISTICS

Selenia WR Pure Energy 5W-30 is the first product with High Fuel Economy System, a special formulation that allows considerable fuel saving compared with products of the same viscosimetric rating.

• It increases protection on the mostly stressed parts of the engine; in particular Selenia WR Pure Energy greatly reduces the danger of turbine soiling, which is the main cause of falling performance and, in prolonged cases, of breakages.
• Selenia WR Pure Energy is therefore a lubricant with very high performance that can combine respect for the environment with its low ash content and protection of increasingly high performance diesel engines.

#### ADVICE ON USE

As per OEM owner manual.

Looking for any other product in PETRONAS OIL & LUBRICANTS or other Lubricant ? Just give us a call.


text:
# panda3d.core.CollisionParabola¶

from panda3d.core import CollisionParabola

class CollisionParabola

Bases: CollisionSolid

This defines a parabolic arc, or subset of an arc, similar to the path of a projectile or falling object. It is finite, having a specific beginning and end, but it is infinitely thin.

Think of it as a wire bending from point t1 to point t2 along the path of a pre-defined parabola.

Inheritance diagram

__init__() → None

Creates an invalid parabola.

__init__(parabola: LParabola, t1: float, t2: float) → None

Creates a parabola with the endpoints between t1 and t2 in the parametric space of the parabola.

setParabola(parabola: LParabola) → None

Replaces the parabola specified by this solid.

getParabola() → LParabola

Returns the parabola specified by this solid.

Return type

LParabola

setT1(t1: float) → None

Changes the starting point on the parabola.

getT1() → float

Returns the starting point on the parabola.

setT2(t2: float) → None

Changes the ending point on the parabola.

getT2() → float

Returns the ending point on the parabola.

static getClassType() → TypeHandle
Return type

TypeHandle

property parabola
Getter

Returns the parabola specified by this solid.

Setter

Replaces the parabola specified by this solid.

Return type

LParabola

property t1
Getter

Returns the starting point on the parabola.

Setter

Changes the starting point on the parabola.

Return type

float

property t2
Getter

Returns the ending point on the parabola.

Setter

Changes the ending point on the parabola.

Return type

float


text:
# Fourier Series question

I can do the Fourier series but this question is really confusing

F(x) is 1 for 0<x< pi , 0 for pi < x < 2pi and f(x+2pi) = f(x) for all x

I know that it means that the period is 2pi and L = 2pi/2 = pi

1) Sketch f(x) for -4pi <x < 4pi

I sketched the graph so that is alrite

2) Find the Fourier series for f(x)

This is where it gets confusing. What is f(x)?? what is the function? Is it a unit step function or what?

Thanks.

CompuChip
Homework Helper
F(x) is 1 for 0<x< pi , 0 for pi < x < 2pi and f(x+2pi) = f(x) for all x
I assume that in the first part, you meant to write f(x) instead of F(x). Also the function is now undefined at x = 0, 2 pi, 4 pi, etc., so you may want to include something like: f(0) = 1/2, in the definition.

2) Find the Fourier series for f(x)

This is where it gets confusing. What is f(x)?? what is the function?
I assume this is part b) of the same question, so my guess is they mean the same function you defined above and you have graphed in 1).

Fourier Series

## Homework Statement

I can do the Fourier series but this question is really confusing

F(x) is 1 for 0<x< pi , 0 for pi < x < 2pi and f(x+2pi) = f(x) for all x

I know that it means that the period is 2pi and L = 2pi/2 = pi

1) Sketch f(x) for -4pi <x < 4pi

I sketched the graph so that is alrite

2) Find the Fourier series for f(x)

This is where it gets confusing. What is f(x)?? what is the function? Is it a unit step function or what?

Thanks.

## Homework Equations

Euler coefficient equations.

## The Attempt at a Solution

I can do the solution but I have no idea what f(x) is!

malawi_glenn
Homework Helper
"F(x) is 1 for 0<x< pi , 0 for pi < x < 2pi and f(x+2pi) = f(x) for all x"

you mean:

f(x) is 1 for 0<x< pi , 0 for pi < x < 2pi and f(x+2pi) = f(x) for all x
??

the last statement, f(x+2pi) = f(x), mean that the periodicity of the function is 2pi.

So when doing the fourier series, you only need to know the period and what the function looks within that intervall.

The function f(x) is 1 for 0<x< pi , 0 for pi < x < 2pi, 1 for 2pi < x < 3pi, 0 for 3pi < x < 4pi etc.

But u see how do u integrate that as a function.

You cant put o< x <1 in an integral and integrate right? You see what i mean? I want to know how you right that in a form in which you can integrate.

And yea what you have written is right.

Thanks.

i mean 0 <x < pi and integrate. And you need to know what L to solve a Fourier Coefficient. L is Period/2

HallsofIvy


text:
Stability of correlations and volatility

I had a discussion recently about the stability of volatilities and correlations. If we take for example stocks and bonds (think of DAX and Bund) then I have seen changing volatilities (something like $30\%-15\%$ vola pa. for DAX) in the last years but a consistently strong negative correlation around $-0.5$.

Commercial risk management systems use different half-lives in their weighting schemes reflecting quicker changes in vola and more stability in correlations. This is my feeling for periods like one or two years too.

A consultant told me yesterday that he thinks the other way around and that for him volatility is quite stable (say $30\%$ for stocks) and correlations change a lot.

Although this must depend on the horizon that you observe I strongly disagree and see the stability of correlations higher than the stability of volas.

Which view is more appropriate for a $1-2$ years horizon and what for longer terms?

-

I would entirely separate the investigation and analysis of volatility and correlation between two asset classes.

Think of it this way: If volatility is extremely high then high fluctuation to both, the up and down side will contribute to the stability of high volatility. However, for correlations it makes a big difference whether the large move has been to the up or down side especially the co-variation between, lets say, Dax and Bunds. The opposite holds true as well: If return volatility suddenly decreases then that has obviously a strong impact on your realized volatility measure, but it may not affect correlations at all as long as the covariation is in line with your current realized measure. Neither levels nor historical volatility-correlation patterns have any bearing whatsoever on future relationships between volatility and correlation.

By the way annualized vols for Dax were more in the region 12%-40% over the last couple years.

In summary, its entirely by chance that you observe certain patterns of stability or fluctuation in either volatility or correlation measures but what is not by chance is the ever changing and unpredictable relationships between volatility and correlations. Only when markets as a whole are stressed through exogenous events does one observe the general pattern of higher volatility and higher correlations but that generally applies to assets within the same asset class. The opaque relationship between volatility and correlations was further evidenced in late 2008 when one could pick up dispersion structures for cents on the dollar from exotic desks who attempted to clean up the books before they were entirely dismantled and everyone fired. Not that such structures were a great trade, in fact dispersion decreased further into Q1 2009.

Example: Look at how gold traded in 2008. Every last sell-side analyst in the world predicted staggering gold prices due to the flight to safety and tangible assets. Remember, even money market funds were under assault, even your paper currency under the mattress was getting devalued. And what happened? Gold was massively dumped because of hedge fund liquidations. I know a lot of volatility desks that have been long-term profitable. But to be very honest with you, I hardly ever saw a correlation desk that survived for longer than 5 years. If history has taught me personally one thing then it is that I would not bet a single coin on correlation predictions, at least a lot less than what I at times wager on direction and/or volatility.

-
Thanks for your answer. I am still thinking about correlation as something stable. Maybe rather in a market clusters sense. The correlation of e.g. USD/EUR to equity was quite stable (negative) in the last years while equity vol went up and down. But this is probably note true during longer periods and in an asset-by-asset setting. Also very interesting is your comparison of vol and correlation trading desks. –  Richard Mar 6 '13 at 11:30


text:
## Intermediate Algebra (6th Edition)

Original Equation 6(2-3x)$\geq$12 Distribute 12-18x$\geq$12 Subtract 12 from both sides -18x$\geq$0 Divide both sides by -18 x$\leq$0 Convert to interval notation (-infinity, 0]


text:
# Paolo Amoroso's Journal

## Why I'm boosting more on Mastodon

You know what I envied of those influencers with millions of followers? The magic of tweeting a question and getting valuable answers and advice from knowledgeable people.

I'm no celebrity, but on Mastodon I'm getting the same experience with orders of magnitude fewer followers.

As a retrocomputing enthusiast, it's a lot of fun to explore and program my V20-MBC homebrew Nec V20 computer. But CP/M-86, one of the operating systems the V20-MBC runs, was eclipsed by MS-DOS back in the day, leaving little surviving documentation and literature. Especially about CP/M-86 development.

So the Open Library listing of the book CP/M-86 Assembly Language Programming by Jon Lindsay (Brady Communications Co., 1986) caught my attention. Sadly, the text isn't available. I decided to try to track down the book, starting by asking for help on comp.os.cpm.

Without expecting much, I also posted a toot to my Mastodon account in case anyone had useful clues on the book. What happened next blew my mind.

Within a day the post was boosted over a hundred times, got some fifty stars, and received dozens of valuable replies. The replies contributed promising leads, tagged others who might know something, suggested workarounds or other lines of inquiry, and started a few interesting side conversations. Everyone went out of their way to assist.

I was speechless, breathless. Literally. I didn't even know how to adequately thank the many who chimed in.

This isn't possible on Twitter, where the algorithms boost celebrities and influencers and bury everyone else.

You may think this overwhelming support has something to do with my 1.1K Mastodon followers. But I've been having a similar experience since joining Mastodon ten months ago. I'd say the critical mass is somewhere between a few dozen and a couple hundred followers.

I want to give back. I want to give others the opportunity of a similar positive experience, which is within reach of everyone in the Fediverse. Boosts proved crucial to amplify my quest for help, so I'm boosting more toots for a chance to reach someone who may be interested or willing to help.

People are the ultimate algorithm.


text:
# Is "degree of freedom" singular or plural?

When discussing a theoretical distribution having a single parameter described as a degree of freedom (like the $$t$$ distribution), do we refer to this parameter as degrees of freedom (plural) or degree of freedom (singular). We frequently see expressions such as A t test with 10 degrees of freedom. Could (should) we say A t test with degree of freedom of 10?

I feel that this parameter is a single concept, so discussing it should go with singular? As another example, consider The exact degree of freedom depends on ... Should I write here degree of freedom in its singular form? A reviewer commented that an "s" should be added.

Thanks for this linguistic aid.

• It's a single parameter but it refers to, quite often, multiple degrees, so I would always use the plural. Sep 4 '20 at 18:27